Browse code

http_client Free the old object when the new can't be allocated properly

Olle E. Johansson authored on 21/08/2017 08:57:34
Showing 1 changed files
... ...
@@ -172,7 +172,7 @@ curl_con_pkg_t* curl_get_pkg_connection(curl_con_t *con)
172 172
 		}
173 173
 		ccp = ccp->next;
174 174
 	}
175
-	LM_DBG("curl_get_pkg_connection no success in looking for pkg memory for httpcon: [%.*s]\n", con->name.len, con->name.s);
175
+	LM_ERR("curl_get_pkg_connection no success in looking for pkg memory for httpcon: [%.*s]\n", con->name.len, con->name.s);
176 176
 	return NULL;
177 177
 }
178 178
 
... ...
@@ -751,8 +751,9 @@ curl_con_t *curl_init_con(str *name)
751 751
 	ccp = (curl_con_pkg_t*) pkg_malloc(sizeof(curl_con_pkg_t));
752 752
 	if(ccp == NULL)
753 753
 	{
754
-		shm_free(ccp);
755
-		LM_ERR("no shm memory\n");
754
+		/* We failed to allocate ccp, so let's free cc and quit */
755
+		shm_free(cc);
756
+		LM_ERR("no pkg memory available\n");
756 757
 		return NULL;
757 758
 	}
758 759