浏览代码

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.
Andrei Pelinescu-Onciul 16 年之前
父节点
当前提交
3ccb9c819b
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      rpc_lookup.c

+ 2 - 2
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;