Changeset: 45223a915a31 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/45223a915a31
Modified Files:
monetdb5/mal/mal_runtime.c
Branch: Sep2022
Log Message:
Fix memory leak.
diffs (54 lines):
diff --git a/monetdb5/mal/mal_runtime.c b/monetdb5/mal/mal_runtime.c
--- a/monetdb5/mal/mal_runtime.c
+++ b/monetdb5/mal/mal_runtime.c
@@ -34,7 +34,7 @@ static oid qtag= 1; // A unique query i
UserStats USRstats = NULL;
size_t usrstatscnt = 0;
-static void
+static inline void
clearUSRstats(size_t idx)
{
USRstats[idx] = (struct USERSTAT){0};
@@ -87,10 +87,8 @@ updateUserStats(Client cntxt, MalBlkPtr
}
if (USRstats[idx].username == NULL || USRstats[idx].user != cntxt->user
|| strcmp(USRstats[idx].username, cntxt->username) != 0) {
- if (USRstats[idx].username)
- GDKfree(USRstats[idx].username);
- if (USRstats[idx].maxquery)
- GDKfree(USRstats[idx].maxquery);
+ GDKfree(USRstats[idx].username);
+ GDKfree(USRstats[idx].maxquery);
clearUSRstats(idx);
USRstats[idx].user = cntxt->user;
USRstats[idx].username = GDKstrdup(cntxt->username);
@@ -101,8 +99,7 @@ updateUserStats(Client cntxt, MalBlkPtr
USRstats[idx].started = started;
USRstats[idx].finished = finished;
USRstats[idx].maxticks = ticks;
- if (USRstats[idx].maxquery)
- GDKfree(USRstats[idx].maxquery);
+ GDKfree(USRstats[idx].maxquery);
USRstats[idx].maxquery = GDKstrdup(query);
}
}
@@ -147,7 +144,7 @@ isaSQLquery(MalBlkPtr mb){
*/
/* clear the next entry for a new call unless it is a running query */
-static void
+static inline void
clearQRYqueue(size_t idx)
{
QRYqueue[idx] = (struct QRYQUEUE){0};
@@ -246,7 +243,8 @@ runtimeProfileInit(Client cntxt, MalBlkP
QRYqueue[j].finished = 0;
QRYqueue[j].start = time(0);
q = isaSQLquery(mb);
- QRYqueue[j].query = q? GDKstrdup(q):0;
+ GDKfree(QRYqueue[j].query);
+ QRYqueue[j].query = GDKstrdup(q); /* NULL in, NULL out
*/
GDKfree(QRYqueue[j].username);
if (!GDKembedded())
QRYqueue[j].username =
GDKstrdup(cntxt->username);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]