Changeset: f8e88eadd4a8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f8e88eadd4a8
Modified Files:
        sql/backends/monet5/sql_execute.c
Branch: Jul2017
Log Message:

More malloc checks


diffs (40 lines):

diff --git a/sql/backends/monet5/sql_execute.c 
b/sql/backends/monet5/sql_execute.c
--- a/sql/backends/monet5/sql_execute.c
+++ b/sql/backends/monet5/sql_execute.c
@@ -412,6 +412,7 @@ SQLstatementIntern(Client c, str *expr, 
        int oldvtop, oldstop = 1;
        buffer *b;
        char *n;
+       bstream *bs;
        stream *buf;
        str msg = MAL_SUCCEED;
        backend *be, *sql = (backend *) c->sqlcontext;
@@ -470,15 +471,26 @@ SQLstatementIntern(Client c, str *expr, 
        if( b == NULL)
                throw(SQL,"sql.statement",MAL_MALLOC_FAIL);
        n = GDKmalloc(len + 1 + 1);
-       if( n == NULL)
+       if( n == NULL) {
+               GDKfree(b);
                throw(SQL,"sql.statement",MAL_MALLOC_FAIL);
+       }
        strncpy(n, *expr, len);
        n[len] = '\n';
        n[len + 1] = 0;
        len++;
        buffer_init(b, n, len);
        buf = buffer_rastream(b, "sqlstatement");
-       scanner_init(&m->scanner, bstream_create(buf, b->len), NULL);
+       if(buf == NULL) {
+               buffer_destroy(b);//n and b will be freed by the buffer
+               throw(SQL,"sql.statement",MAL_MALLOC_FAIL);
+       }
+       bs = bstream_create(buf, b->len);
+       if(bs == NULL) {
+               buffer_destroy(b);//n and b will be freed by the buffer
+               throw(SQL,"sql.statement",MAL_MALLOC_FAIL);
+       }
+       scanner_init(&m->scanner, bs, NULL);
        m->scanner.mode = LINE_N;
        bstream_next(m->scanner.rs);
 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to