fix possible double free

This commit is contained in:
cryptonote-social 2020-08-15 16:24:14 -07:00
parent 1caf52f1df
commit a0df6f931c
2 changed files with 4 additions and 3 deletions

View File

@ -97,7 +97,6 @@ int main(int argc, char* argv[]) {
pl_resp = pool_login(&pl_args);
if (pl_resp.code < 0) {
printf("Oh no, login 2 failed: %s\n", pl_resp.message);
free((void*)pl_resp.message);
}
if (pl_resp.code > 1) {
printf("Pool server didn't like login 2 info: %s\n", pl_resp.message);

View File

@ -369,12 +369,13 @@ func handlePoke(wasMining bool, poke int, stopper *uint32, wg *sync.WaitGroup) i
if poke == INCREASE_THREADS_POKE {
atomic.StoreUint32(stopper, 1)
wg.Wait()
configMutex.Lock()
t := rx.AddThread()
if t < 0 {
configMutex.UnLock()
crylog.Error("Failed to add another thread")
return USE_CACHED
}
configMutex.Lock()
threads = t
configMutex.Unlock()
crylog.Info("Increased # of threads to:", t)
@ -384,12 +385,13 @@ func handlePoke(wasMining bool, poke int, stopper *uint32, wg *sync.WaitGroup) i
if poke == DECREASE_THREADS_POKE {
atomic.StoreUint32(stopper, 1)
wg.Wait()
configMutex.Lock()
t := rx.RemoveThread()
if t < 0 {
configMutex.Unlock()
crylog.Error("Failed to decrease threads")
return USE_CACHED
}
configMutex.Lock()
threads = t
configMutex.Unlock()
crylog.Info("Decreased # of threads to:", t)