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

Try to reallocate buffers when terms are too long

Part of the fix for bug 6375


diffs (29 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
@@ -412,8 +412,9 @@ shortRenderingTerm(MalBlkPtr mb, MalStkP
        ValRecord *val;
        char *cv =0;
        int varid = getArg(p,idx);
+       size_t len = BUFSIZ;
 
-       s= GDKmalloc(BUFSIZ);
+       s= GDKmalloc(len);
        if( s == NULL)
                return NULL;
        *s = 0;
@@ -421,7 +422,13 @@ shortRenderingTerm(MalBlkPtr mb, MalStkP
        if( isVarConstant(mb,varid) ){
                val =&getVarConstant(mb, varid);
                VALformat(&cv, val);
-               snprintf(s,BUFSIZ,"%s",cv);
+               if (strlen(cv) >= len) {
+                       len = strlen(cv);
+                       s = GDKrealloc(s, len + 1);
+                       if (s == NULL)
+                               return NULL;
+               }
+               snprintf(s,len + 1,"%s",cv);
        } else {
                val = &stk->stk[varid];
                VALformat(&cv, val);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to