aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_curl.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-05-26 16:15:58 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2005-05-26 16:15:58 +0000
commitb2e705e4c1cdc7c32c1e7d1d115d430e2cbace68 (patch)
tree1e7daf3479ea22587ebd74112756a8cba027e722 /apps/app_curl.c
parente9f4f7e70205db1c750db16861718462bf31d37d (diff)
fix seg fault when the app is called on an invalid url (bug #4389)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5775 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_curl.c')
-rwxr-xr-xapps/app_curl.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/apps/app_curl.c b/apps/app_curl.c
index ecc4a2c6b..f81071aa8 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;