client: Fix two memory leaks in handle_job_opt()
authorBart Van Assche <bvanassche@acm.org>
Sun, 24 May 2020 20:35:54 +0000 (13:35 -0700)
committerBart Van Assche <bvanassche@acm.org>
Sun, 24 May 2020 22:11:33 +0000 (15:11 -0700)
commit9b67d883adebfb3bbe594ca5c2e3edf1cd77693f
tree150d5af822162295c37cdf68fcecc0c979fba514
parentc42b48fed60105b4bcd443b9a013548e9e9c43e0
client: Fix two memory leaks in handle_job_opt()

Do not leak p if pdu->global != 0.

This is an improvement for a previous attempt to fix handle_job_opt(). See
also commit ebae36a28aee ("client: Fix memory leaks in handle_job_opt()").

Do not leak strdup(pdu->name) when calling json_object_add_value_string().
That function namely (indirectly) duplicates its 'name' argument.

This patch fixes the following Coverity complaint:

CID 169311 (#1 of 1): Resource leak (RESOURCE_LEAK)
9. leaked_storage: Variable p going out of scope leaks the storage it points to.

Signed-off-by: Bart Van Assche <bvanassche@acm.org>
client.c