[sr-dev] git:master: core: destroy_rpcs fix: don't try to free unalloc. data

Andrei Pelinescu-Onciul andrei at iptel.org
Fri May 29 11:08:23 CEST 2009


Module: sip-router
Branch: master
Commit: 3ccb9c819ba1c54601eafebed434e550cb39c1dc
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=3ccb9c819ba1c54601eafebed434e550cb39c1dc

Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Fri May 29 11:07:20 2009 +0200

core: destroy_rpcs fix: don't try to free unalloc. data

destroy_rpcs() can be called without  init_rpcs() being called
first (e.g. unknown command line param) => don't blindly free
everything, check first if the arrays were allocated.

---

 rpc_lookup.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/rpc_lookup.c b/rpc_lookup.c
index 606a7ca..c1e1a6d 100644
--- a/rpc_lookup.c
+++ b/rpc_lookup.c
@@ -67,8 +67,8 @@ void destroy_rpcs()
 			pkg_free(e);
 		}
 	}
-	pkg_free(rpc_hash_table.table);
-	pkg_free(rpc_sarray);
+	if (rpc_hash_table.table) pkg_free(rpc_hash_table.table);
+	if (rpc_sarray) pkg_free(rpc_sarray);
 	rpc_hash_table.table=0;
 	rpc_hash_table.size=0;
 	rpc_sarray=0;




More information about the sr-dev mailing list