diff --git a/funcs/func_curl.c b/funcs/func_curl.c
index 8f49c16a6b76515ec188fe93f92a7c601fe2f348..e011461fe03896294db8b49a0acb8c2df9638924 100644
--- a/funcs/func_curl.c
+++ b/funcs/func_curl.c
@@ -608,6 +608,7 @@ static int acf_curl_helper(struct ast_channel *chan, const char *cmd, char *info
 
 	if (!(curl = ast_threadstorage_get(&curl_instance, sizeof(*curl)))) {
 		ast_log(LOG_ERROR, "Cannot allocate curl structure\n");
+		ast_free(str);
 		return -1;
 	}