fix seg fault when the app is called on an invalid url (bug #4389)

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5775 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant 2005-05-26 16:15:58 +00:00
parent dc21f68a95
commit 8b81d9e384
1 changed files with 7 additions and 5 deletions

View File

@ -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;