ras-record: fix memory leak when sqlite3_open_v2 fails
PATCH 1/1 ras-record: fix memory leak when sqlite3_open_v2 fails
According to SQLite documentation, a database connection handle is usually returned, even if an error occurs. This behavior has caused rasdaemon to leak memory when opening a database is failed. Now, even if sqlite3_open_v2() does not return SQLITE_OK, rasdaemon tries to release SQLite database handle by calling sqlite3_close_v2().
Signed-off-by lvying6 <[email protected]>
--- ras-record.c | 2 ++ 1 file changed, 2 insertions(+)
ras-record.c +2 -0
@@ -726,6 +726,8 @@ int ras_mc_event_opendb(unsigned cpu, struct ras_events *ras) }while (rc ==SQLITE_BUSY );if (rc !=SQLITE_OK ) { +sqlite3_close_v2 (db); + db =NULL ;log (TERM ,LOG_ERR ,"cpu %u: Failed to connect to %s: error = %d\n" , cpu,SQLITE_RAS_DB , rc);
Signature · 1 line
1.8.3.1