[asterisk-commits] file: branch group/pimp_my_sip r383656 - /team/group/pimp_my_sip/res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Mar 23 20:51:16 CDT 2013


Author: file
Date: Sat Mar 23 20:51:12 2013
New Revision: 383656

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383656
Log:
Fix memory leak where the ast_strs were not being freed.

Modified:
    team/group/pimp_my_sip/res/res_sip_authenticator_digest.c

Modified: team/group/pimp_my_sip/res/res_sip_authenticator_digest.c
URL: http://svnview.digium.com/svn/asterisk/team/group/pimp_my_sip/res/res_sip_authenticator_digest.c?view=diff&rev=383656&r1=383655&r2=383656
==============================================================================
--- team/group/pimp_my_sip/res/res_sip_authenticator_digest.c (original)
+++ team/group/pimp_my_sip/res/res_sip_authenticator_digest.c Sat Mar 23 20:51:12 2013
@@ -192,7 +192,7 @@
  */
 static int build_nonce(struct ast_str **nonce, const char *timestamp, const pjsip_rx_data *rdata, const char *realm)
 {
-	struct ast_str *str = ast_str_create(64);
+	RAII_VAR(struct ast_str *, str, ast_str_create(64), ast_free_ptr);
 	RAII_VAR(char *, eid, ao2_global_obj_ref(entity_id), ao2_cleanup);
 	char hash[32];
 
@@ -225,7 +225,8 @@
 	char *timestamp = strsep(&copy, "/");
 	int timestamp_int;
 	time_t now = time(NULL);
-	struct ast_str *calculated = ast_str_create(64);
+	RAII_VAR(struct ast_str *, calculated, ast_str_create(64), ast_free_ptr);
+
 	if (!copy) {
 		/* Clearly a bad nonce! */
 		return 0;
@@ -341,12 +342,12 @@
 	pj_str_t qop;
 	pj_str_t pj_nonce;
 	pjsip_auth_srv auth_server;
+	RAII_VAR(struct ast_str *, nonce, ast_str_create(64), ast_free_ptr);
 	struct ast_str *nonce;
 	char time_buf[32];
 	time_t timestamp = time(NULL);
 	snprintf(time_buf, sizeof(time_buf), "%d", (int) timestamp);
 
-	nonce = ast_str_create(64);
 	build_nonce(&nonce, time_buf, rdata, auth->realm);
 
 	setup_auth_srv(tdata->pool, &auth_server, auth);




More information about the asterisk-commits mailing list