data-request-example: free memory before exiting after a target register failure

Signed-off-by: Tatiana Leon <Tatiana.Leon@digi.com>
This commit is contained in:
Tatiana Leon 2023-10-09 10:46:38 +02:00
parent 03f2e3dd7f
commit ddc4623f0b
1 changed files with 4 additions and 2 deletions

View File

@ -195,12 +195,14 @@ int main(int argc, char *argv[])
return EXIT_FAILURE;
} else if (resp.code != 0) {
if (resp.hint)
if (resp.hint) {
log_error("%s: Cannot register target '%s': CCCSD error, %s (%d)",
__func__, TARGET_GET_TIME, resp.hint, resp.code);
else
free(resp.hint);
} else {
log_error("%s: Cannot register target '%s': CCCSD error, %d",
__func__, TARGET_GET_TIME, resp.code);
}
return EXIT_FAILURE;
}