From 35235b8647eae94a46db9d60d99344ee560c570b Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Fri, 2 Apr 2010 21:50:48 +0200 Subject: [PATCH] Lets fix calling INGfreeDescriptor before INGfreeINGresult as INGfreeINGresult free the whole INGresult struct and the descriptor is part of that. --- bacula/src/cats/myingres.c | 9 ++++++--- bacula/src/cats/myingres.sc | 8 +++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/bacula/src/cats/myingres.c b/bacula/src/cats/myingres.c index 227464b0ee..29cf2f2623 100644 --- a/bacula/src/cats/myingres.c +++ b/bacula/src/cats/myingres.c @@ -272,7 +272,6 @@ static void INGfreeINGresult(INGresult *ing_res) free(ing_res->fields); } free(ing_res); - ing_res = NULL; } static inline ING_ROW *INGgetRowSpace(INGresult *ing_res) { @@ -523,16 +522,20 @@ INGresult *INGquery(B_DB *mdb, INGconn *conn, const char *query) if (!desc) { return NULL; } + res = INGgetINGresult(desc); if (!res) { return NULL; } + rows = INGfetchAll(query, res); + if (rows < 0) { - INGfreeINGresult(res); INGfreeDescriptor(desc); + INGfreeINGresult(res); return NULL; } + return res; } void INGclear(INGresult *res) @@ -540,8 +543,8 @@ void INGclear(INGresult *res) if (res == NULL) { return; } - INGfreeINGresult(res); INGfreeDescriptor(res->sqlda); + INGfreeINGresult(res); } INGconn *INGconnectDB(char *dbname, char *user, char *passwd) { diff --git a/bacula/src/cats/myingres.sc b/bacula/src/cats/myingres.sc index 2ea172a5a6..e065313f4f 100644 --- a/bacula/src/cats/myingres.sc +++ b/bacula/src/cats/myingres.sc @@ -297,7 +297,6 @@ static void INGfreeINGresult(INGresult *ing_res) free(ing_res->fields); } free(ing_res); - ing_res = NULL; } static inline ING_ROW *INGgetRowSpace(INGresult *ing_res) @@ -552,17 +551,20 @@ INGresult *INGquery(B_DB *mdb, INGconn *conn, const char *query) if (!desc) { return NULL; } + res = INGgetINGresult(desc); if (!res) { return NULL; } + rows = INGfetchAll(query, res); if (rows < 0) { - INGfreeINGresult(res); INGfreeDescriptor(desc); + INGfreeINGresult(res); return NULL; } + return res; } @@ -572,8 +574,8 @@ void INGclear(INGresult *res) return; } - INGfreeINGresult(res); INGfreeDescriptor(res->sqlda); + INGfreeINGresult(res); } INGconn *INGconnectDB(char *dbname, char *user, char *passwd) -- 2.39.5