Update of /cvsroot/monetdb/pathfinder/runtime
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv29834/runtime

Modified Files:
        pathfinder.mx 
Log Message:

fixed several bugs in the handling of the value parsing buffer of the 
xquery_client struct:

- re-allocation is required if the new string is *longer* than the current 
buffer,
  not if it is *shorter*...
- properly maintain the vallen info with each (re-/de-)allocation of the val 
buffer

[This keeps MonetDB/XQuery from crashing horribly on some TPoX queries ...]


Index: pathfinder.mx
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/runtime/pathfinder.mx,v
retrieving revision 1.318
retrieving revision 1.319
diff -u -d -r1.318 -r1.319
--- pathfinder.mx       5 Apr 2007 10:23:16 -0000       1.318
+++ pathfinder.mx       5 Apr 2007 14:53:16 -0000       1.319
@@ -4460,10 +4460,13 @@
                     /* we no longer do fancy strTostr for strings; just copied 
as-is */
                    char *t, *s = argval[l];
                    int len = strlen(s)*2;
-                   if (len <= ctx->vallen) {
+                   if (len >= ctx->vallen) {
                        if (ctx->val) GDKfree(ctx->val);
-                       ctx->val = GDKmalloc(len+1);
-                       if (ctx->val == NULL) return "xquery_function_call: 
malloc failure.\n";
+                       ctx->val = GDKmalloc(ctx->vallen = len+1);
+                       if (ctx->val == NULL) {
+                           ctx->vallen = 0;
+                           return "xquery_function_call: malloc failure.\n";
+                       }
                    }
                    for(t=(char*) ctx->val; *s; s++) { *t++ = *s; }
                     *t = 0;
@@ -4812,7 +4815,9 @@
     if (ctx->val == NULL || ctx->buf == NULL) {
             if (ctx->buf) GDKfree(ctx->buf);
             if (ctx->val) GDKfree(ctx->val);
+            ctx->buf = ctx->val = NULL;
             ctx->buflen = 0;
+            ctx->vallen = 0;
             return "xquery_client_alloc: failed to allocate.\n";
     }
     ctx->repeat_stk = CNTXTnew(ctx->stk);


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Monetdb-pf-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins

Reply via email to