Index: funcs/func_curl.c =================================================================== --- funcs/func_curl.c (revision 292308) +++ funcs/func_curl.c (working copy) @@ -477,18 +477,24 @@ static int acf_curl_exec(struct ast_channel *chan, struct ast_str *fields = ast_str_create(ast_str_strlen(str) / 2); struct ast_str *values = ast_str_create(ast_str_strlen(str) / 2); int rowcount = 0; - while ((piece = strsep(&remainder, "&"))) { - char *name = strsep(&piece, "="); - ast_uri_decode(piece); - ast_uri_decode(name); - ast_str_append(&fields, 0, "%s%s", rowcount ? "," : "", name); - ast_str_append(&values, 0, "%s%s", rowcount ? "," : "", piece); - rowcount++; + if (fields != NULL && values != NULL) { + while ((piece = strsep(&remainder, "&"))) { + char *name = strsep(&piece, "="); + if (piece != NULL) { + ast_uri_decode(piece); + ast_uri_decode(name); + ast_str_append(&fields, 0, "%s%s", rowcount ? "," : "", name); + ast_str_append(&values, 0, "%s%s", rowcount ? "," : "", piece); + rowcount++; + } + } + pbx_builtin_setvar_helper(chan, "~ODBCFIELDS~", ast_str_buffer(fields)); + ast_copy_string(buf, ast_str_buffer(values), len); } - pbx_builtin_setvar_helper(chan, "~ODBCFIELDS~", ast_str_buffer(fields)); - ast_copy_string(buf, ast_str_buffer(values), len); - ast_free(fields); - ast_free(values); + if (fields) + ast_free(fields); + if (values) + ast_free(values); } else { ast_copy_string(buf, ast_str_buffer(str), len); }