fix memory leak for security issue 74/155774/2 accepted/tizen/unified/20171018.062356 submit/tizen/20171017.072940
authorjkjo92 <jkjo92@samsung.com>
Mon, 16 Oct 2017 06:36:26 +0000 (15:36 +0900)
committerjkjo92 <jkjo92@samsung.com>
Tue, 17 Oct 2017 07:18:40 +0000 (16:18 +0900)
Change-Id: I2409b045ec0c46fc99cf589ae06d58de2ed23289
Signed-off-by: jkjo92 <jkjo92@samsung.com>
src/oauth2_manager.c

index 9baeb3c..5e02b6e 100755 (executable)
@@ -477,7 +477,10 @@ __store_curl_response(void *ptr, size_t size, size_t nmemb, void *data)
                memcpy(*result, ptr, size * nmemb);
        } else {
                size_t len = strlen(*result);
+               char* result_temp = *result;
                *result = realloc(*result, len + size * nmemb + 1);
+               if (*result == NULL)
+                       OAUTH2_FREE(result_temp);
                OAUTH2_RETURN_VAL(*result, {}, OAUTH2_ERROR_OUT_OF_MEMORY,
                        "Out of memory");
                memcpy(*result + len, ptr, size * nmemb);