From 0712d0482ca8e93485064dd96b49a947eda7e266 Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 17 Jan 2018 10:45:37 +0900 Subject: [PATCH] Fix potential memory leak issue when setting invocation name several times Change-Id: I5de2aed2bd97e571b3c0fc60b81ad7993f17ac9e Signed-off-by: Jihoon Kim --- client/vc_client.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/vc_client.c b/client/vc_client.c index 2602c1a..cb7be34 100644 --- a/client/vc_client.c +++ b/client/vc_client.c @@ -494,12 +494,13 @@ int vc_client_set_invocation_name(vc_h vc, const char* invocation_name) if (NULL == client) return VC_ERROR_INVALID_PARAMETER; + if (NULL != client->invocation_name) + free(client->invocation_name); + + client->invocation_name = NULL; + if (NULL != invocation_name) { client->invocation_name = strdup(invocation_name); - } else { - if (NULL != client->invocation_name) - free(client->invocation_name); - client->invocation_name = NULL; } return 0; } -- 2.7.4