diff --git a/apps/app_curl.c b/apps/app_curl.c index ecc4a2c6bef4c649aae4de7642ed6cee4b02611f..f81071aa8489549567ef06714cfb31970e48c21e 100755 --- a/apps/app_curl.c +++ b/apps/app_curl.c @@ -115,13 +115,15 @@ static int curl_exec(struct ast_channel *chan, void *data) curl_easy_perform(curl); curl_easy_cleanup(curl); - chunk.memory[chunk.size] = '\0'; - if (chunk.memory[chunk.size - 1] == 10) - chunk.memory[chunk.size - 1] = '\0'; + if (chunk.memory) { + chunk.memory[chunk.size] = '\0'; + if (chunk.memory[chunk.size - 1] == 10) + chunk.memory[chunk.size - 1] = '\0'; - pbx_builtin_setvar_helper(chan, "CURL", chunk.memory); + pbx_builtin_setvar_helper(chan, "CURL", chunk.memory); - free(chunk.memory); + free(chunk.memory); + } } else { ast_log(LOG_ERROR, "Cannot allocate curl structure\n"); res = -1;