Skip to content

Commit cb309e7

Browse files
committed
Fix memory leak on incorrect syntax
1 parent 42eebd3 commit cb309e7

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/hoel-pgsql.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ int h_execute_query_pgsql(const struct _h_connection * conn, const char * query,
214214
y_log_message(Y_LOG_LEVEL_ERROR, "Error executing sql query");
215215
y_log_message(Y_LOG_LEVEL_DEBUG, "Error message: \"%s\"", PQerrorMessage(((struct _h_pgsql *)conn->connection)->db_handle));
216216
y_log_message(Y_LOG_LEVEL_DEBUG, "Query: \"%s\"", query);
217+
PQclear(res);
217218
ret = H_ERROR_QUERY;
218219
} else {
219220
nfields = PQnfields(res);
@@ -304,6 +305,7 @@ int h_execute_query_json_pgsql(const struct _h_connection * conn, const char * q
304305
y_log_message(Y_LOG_LEVEL_ERROR, "Error executing sql query");
305306
y_log_message(Y_LOG_LEVEL_DEBUG, "Error message: \"%s\"", PQerrorMessage(((struct _h_pgsql *)conn->connection)->db_handle));
306307
y_log_message(Y_LOG_LEVEL_DEBUG, "Query: \"%s\"", query);
308+
PQclear(res);
307309
ret = H_ERROR_QUERY;
308310
} else {
309311
nfields = PQnfields(res);

0 commit comments

Comments
 (0)