some memory leakage fixes
This commit is contained in:
@ -162,6 +162,7 @@ struct worker_thread_s {
|
||||
int checker_cnt;
|
||||
ht_queue_t *terminator_queue;
|
||||
verify_work_handle_t *vwh;
|
||||
char* rememberPropagatedOutput;
|
||||
};
|
||||
|
||||
typedef struct worker_thread_s worker_thread_t;
|
||||
@ -315,6 +316,9 @@ int verify_work_destroy(void *handle, void *work_handle) {
|
||||
|
||||
queue_destroy(wt->checker_terminator_queue);
|
||||
free(wt->checker_terminator_queue);
|
||||
|
||||
if (NULL != wt->rememberPropagatedOutput)
|
||||
free(wt->rememberPropagatedOutput);
|
||||
|
||||
free(wt);
|
||||
|
||||
@ -470,6 +474,7 @@ int verify_work(void *handle, void *work_handle, char *input, htbuffer_t *output
|
||||
wt->mutex = vwh->result_mutex;
|
||||
wt->cond = vwh->result_cond;
|
||||
wt->result = vwh->result;
|
||||
wt->rememberPropagatedOutput = NULL;
|
||||
wt->checker_terminator_queue = (ht_queue_t*) htmalloc(sizeof(ht_queue_t));
|
||||
queue_init(wt->checker_terminator_queue);
|
||||
wt->checker_cnt = 0;
|
||||
@ -505,7 +510,9 @@ int verify_work(void *handle, void *work_handle, char *input, htbuffer_t *output
|
||||
// snprintf(output, ANSWER_BUFSIZE, vwh->result->output);
|
||||
htbuffer_strcpy(output, vwh->result->output);
|
||||
|
||||
free(vwh->result->output);
|
||||
/* this belongs to the worker thread, it will be freed when the worker thread is cleaned up */
|
||||
/* free(vwh->result->output); */
|
||||
/* vwh->result->output = NULL; */
|
||||
|
||||
return vwh->result->result;
|
||||
}
|
||||
@ -842,6 +849,7 @@ static void *worker_thread(void *arg) {
|
||||
/* we can write the result */
|
||||
wt->result->output = (char*) htmalloc(sizeof(char) * (strlen(wt->output)+15)); /* enough for the output
|
||||
plus <><> and prefix */
|
||||
wt->rememberPropagatedOutput = wt->result->output;
|
||||
switch (result) {
|
||||
case SMM_LOCAL_TEMP_NOK:
|
||||
sprintf(wt->result->output, "<TNOK><%s>", wt->output);
|
||||
|
Reference in New Issue
Block a user