Changeset: 05179eaa240d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=05179eaa240d
Modified Files:
        monetdb5/mal/Tests/tst017.mal
        monetdb5/mal/mal_parser.c
Branch: headless
Log Message:

Fix the parser segfaults


diffs (132 lines):

diff --git a/monetdb5/mal/Tests/tst017.mal b/monetdb5/mal/Tests/tst017.mal
--- a/monetdb5/mal/Tests/tst017.mal
+++ b/monetdb5/mal/Tests/tst017.mal
@@ -5,4 +5,4 @@
        z := cbp.getLRefCount(b);
        io.print(z);
        (l,r) := algebra.join(b,b);
-       io.print(l,r));
+       io.print(l,r);
diff --git a/monetdb5/mal/mal_parser.c b/monetdb5/mal/mal_parser.c
--- a/monetdb5/mal/mal_parser.c
+++ b/monetdb5/mal/mal_parser.c
@@ -849,8 +849,8 @@
  * which starts with an operand.
  * This code is used in both positions of the expression
 */
-int
-term(Client cntxt, MalBlkPtr curBlk, InstrPtr curInstr, int ret)
+static int
+term(Client cntxt, MalBlkPtr curBlk, InstrPtr *curInstr, int ret)
 {
        int i, idx, flag, free = 1;
        ValRecord cst;
@@ -871,19 +871,19 @@
                                        setVarFixed(curBlk,cstidx);
                                } else {
                                        cstidx = defConstant(curBlk,tpe,&cst);
-                                       setPolymorphic(curInstr,tpe, FALSE);
+                                       setPolymorphic(*curInstr,tpe, FALSE);
                                        setVarFixed(curBlk,cstidx);
                                        free = 0;
                                }
                        } else if( cst.vtype != getVarType(curBlk,cstidx).type){
                                cstidx = defConstant(curBlk, 
newMALtype(cst.vtype), &cst);
-                               setPolymorphic(curInstr, newMALtype(cst.vtype), 
FALSE);
+                               setPolymorphic(*curInstr, 
newMALtype(cst.vtype), FALSE);
                                free = 0;
                        }
                        /* protect against leaks coming from constant reuse */
                        if (free && ATOMextern(cst.vtype) && cst.val.pval)
                                VALclear(&cst);
-                       curInstr = pushArgument(curBlk,curInstr,cstidx);
+                       *curInstr = pushArgument(curBlk,*curInstr,cstidx);
                        return ret;
                } else {
                        /* add a new constant */
@@ -893,10 +893,10 @@
                        if( i != 3 && tpe.type == TYPE_any)
                                return 3;
                        cstidx = defConstant(curBlk,tpe,&cst);
-                       setPolymorphic(curInstr,tpe, FALSE);
+                       setPolymorphic(*curInstr,tpe, FALSE);
                        if( flag )
                                setVarFixed(curBlk,cstidx);
-                       curInstr = pushArgument(curBlk,curInstr,cstidx);
+                       *curInstr = pushArgument(curBlk,*curInstr,cstidx);
                        return ret;
                }
        } else if( (i= idLength(cntxt))){
@@ -908,15 +908,15 @@
                        advance(cntxt,i);
                        propList(cntxt,idx);
                }
-               curInstr= pushArgument(curBlk,curInstr,idx);
+               *curInstr= pushArgument(curBlk,*curInstr,idx);
        } else if (currChar(cntxt) == ':'){
                tpe = typeElm(cntxt, newMALtype(TYPE_any));
                if( i != 3 && tpe.type == TYPE_any)
                        return 3;
-               setPolymorphic(curInstr,tpe,FALSE);
+               setPolymorphic(*curInstr,tpe,FALSE);
                idx = newTypeVariable(curBlk, tpe );
                propList(cntxt,idx);
-               curInstr = pushArgument(curBlk,curInstr,idx);
+               *curInstr = pushArgument(curBlk,*curInstr,idx);
                return ret;
        }
        return 0;
@@ -1482,7 +1482,7 @@
 
 /* The parameter of parseArguments is the return value of the enclosing 
function. */
 int
-parseArguments(Client cntxt, MalBlkPtr curBlk, InstrPtr curInstr)
+parseArguments(Client cntxt, MalBlkPtr curBlk, InstrPtr *curInstr)
 {
        while( currChar(cntxt)!= ')'){
                switch(term(cntxt,curBlk,curInstr,0)){
@@ -1492,7 +1492,7 @@
                case 3: return 3;
                default:
                        parseError(cntxt,"<factor> expected\n");
-                       pushInstruction(curBlk,curInstr);
+                       pushInstruction(curBlk,*curInstr);
                        skipToEnd(cntxt);
                        return 1;
                }
@@ -1629,7 +1629,7 @@
        if (currChar(cntxt) == '('){
                        /* parse multi assignment */
                advance(cntxt,1);
-               switch (parseArguments(cntxt, curBlk, curInstr)){
+               switch (parseArguments(cntxt, curBlk, &curInstr)){
                case 2: goto part2;
                default:
                case 3: goto part3;
@@ -1675,7 +1675,7 @@
                        return;
                }
                advance(cntxt,1);
-               switch (parseArguments(cntxt, curBlk, curInstr)){
+               switch (parseArguments(cntxt, curBlk, &curInstr)){
                case 2: goto part2;
                default:
                case 3: goto part3;
@@ -1686,7 +1686,7 @@
                goto part3;
        }
        /* Handle the ordinary assignments and expressions */
-               switch(term(cntxt,curBlk,curInstr,2)){
+               switch(term(cntxt,curBlk,&curInstr,2)){
                case 2: goto part2;
                case 3: goto part3;
                }
@@ -1701,7 +1701,7 @@
                        curInstr= pushArgument(curBlk,curInstr,varid);
                        goto part3;
                }
-               switch(term(cntxt,curBlk,curInstr,3)){
+               switch(term(cntxt,curBlk,&curInstr,3)){
                case 2: goto part2;
                case 3: goto part3;
                }
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to