Changeset: 9064e6738a9c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9064e6738a9c
Modified Files:
        sql/backends/monet5/sql_gencode.c
Branch: Nov2019
Log Message:

Don't lose pointer on a realloc failure


diffs (27 lines):

diff --git a/sql/backends/monet5/sql_gencode.c 
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -426,16 +426,20 @@ static int
                        const char *nme = 
(op->op3)?op->op3->op4.aval->data.val.sval:op->cname;
 
                        if ((nr + 100) > len) {
-                               buf = GDKrealloc(buf, len*=2);
-                               if(buf == NULL)
+                               char *tmp = GDKrealloc(buf, len*=2);
+                               if (tmp == NULL) {
+                                       GDKfree(buf);
+                                       buf = NULL;
                                        break;
+                               }
+                               buf = tmp;
                        }
 
                        nr += snprintf(buf+nr, len-nr, "%s %s(%u,%u)%c", nme, 
t->type->sqlname, t->digits, t->scale, n->next?',':' ');
                }
                s = buf;
        }
-       if(buf) {
+       if (buf) {
                o = newFcnCall(curBlk, remoteRef, putRef);
                o = pushArgument(curBlk, o, q);
                o = pushStr(curBlk, o, s);      /* signature */
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to