summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJose M. Guisado <jguisado@soleta.eu>2021-03-11 14:37:21 +0100
committerOpenGnSys Support Team <soporte-og@soleta.eu>2021-03-11 14:39:07 +0100
commit829f8d8ac97e94619259374fd1f7e00cdf97c2a8 (patch)
treecbc4072ed96c6db26fc9cd011af845e7d92a868b /src
parente68fefeac780e6c87c6ca4722027288356eb0cc8 (diff)
#997 Remove unnecessary strdup in og_dbi_queue_*
After executing an scheduled command/proc/task valgrind reported leaks inside og_dbi_queue_{command,procedure,task}. String duplication is not being freed after using them. ==21281== 36 bytes in 1 blocks are definitely lost in loss record 470 of 592 ... ==21281== by 0x113DCB: og_dbi_queue_procedure (rest.c:2748) ==21281== by 0x113F91: og_dbi_queue_task (rest.c:2804) ==21281== by 0x114392: og_schedule_run (rest.c:2916) ==21281== by 0x112059: og_agent_timer_cb (schedule.c:441) ... ==21281== by 0x10E2A5: main (main.c:100) These strdup are not necessary because the dbi result is not freed before using them, it's safe to use the dbi result's reference to this string. Fix previous memleaks when executing scheduled commands, procedures and tasks.
Diffstat (limited to 'src')
-rw-r--r--src/rest.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/rest.c b/src/rest.c
index 8826d66..e7f2f52 100644
--- a/src/rest.c
+++ b/src/rest.c
@@ -2745,7 +2745,7 @@ int og_dbi_queue_procedure(struct og_dbi *dbi, struct og_task *task)
continue;
}
- task->params = strdup(dbi_result_get_string(result, "parametros"));
+ task->params = dbi_result_get_string(result, "parametros");
task->command_id = dbi_result_get_uint(result, "idcomando");
if (og_queue_task_clients(dbi, task))
return -1;
@@ -2832,7 +2832,7 @@ static int og_dbi_queue_command(struct og_dbi *dbi, uint32_t task_id,
task.task_id = dbi_result_get_uint(result, "idaccion");
task.center_id = dbi_result_get_uint(result, "idcentro");
task.scope = dbi_result_get_uint(result, "idordenador");
- task.params = strdup(dbi_result_get_string(result, "parametros"));
+ task.params = dbi_result_get_string(result, "parametros");
sprintf(query,
"SELECT ip, mac, idordenador FROM ordenadores "