Changeset: a3935a8869c6 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a3935a8869c6
Modified Files:
        monetdb5/mal/mal_listing.c
Branch: Jul2017
Log Message:

Fix a potential memory leak that happens if a realloc fails


diffs (20 lines):

diff --git a/monetdb5/mal/mal_listing.c b/monetdb5/mal/mal_listing.c
--- a/monetdb5/mal/mal_listing.c
+++ b/monetdb5/mal/mal_listing.c
@@ -423,10 +423,14 @@ shortRenderingTerm(MalBlkPtr mb, MalStkP
                val =&getVarConstant(mb, varid);
                VALformat(&cv, val);
                if (strlen(cv) >= len) {
+                       char *nbuf;
                        len = strlen(cv);
-                       s = GDKrealloc(s, len + 1);
-                       if (s == NULL)
+                       nbuf = GDKrealloc(s, len + 1);
+                       if (nbuf == NULL) {
+                               GDKfree(s);
                                return NULL;
+                       }
+                       s = nbuf;
                }
                snprintf(s,len + 1,"%s",cv);
        } else {
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to