瀏覽代碼

- fixed memory leak in flat_reopen_connection, reported by
Bayan William Towfiq <[email protected]>

Jan Janak 20 年之前
父節點
當前提交
e6152f724c
共有 1 個文件被更改,包括 7 次插入0 次删除
  1. 7 0
      modules/db_flatstore/flat_con.c

+ 7 - 0
modules/db_flatstore/flat_con.c

@@ -163,10 +163,17 @@ int flat_reopen_connection(struct flat_con* con)
 
 	if (con->file) {
 		fclose(con->file);
+		con->file = 0;
 
 		fn = get_name(con->id);
+		if (fn == 0) {
+			LOG(L_ERR, "flat_reopen_connection: get_name() failed\n");
+		        return -1;
+		}
 
 		con->file = fopen(fn, "a");
+		pkg_free(fn);
+
 		if (!con->file) {
 			LOG(L_ERR, "flat_reopen_connection: Invalid parameter value\n");
 			return -1;