[Monetdb-developers] [Monetdb-pf-checkins] pathfinder/compiler/mil milprint_summer.c, 1.371, 1.372

Stefan Manegold Stefan.Manegold at cwi.nl
Wed May 2 23:52:05 CEST 2007


ABORT & ROLLBACK

... like CVS, mailing does not provide full ACID semantics ...

Stefan

On Wed, May 02, 2007 at 11:49:28PM +0200, Stefan Manegold wrote:
> Sjoerd,
> 
> didn't like my fix? ;-)
> 
> Well, actually, I'm afraid you just re-introduced the problem:
> in short
> 
> ========
> size_t maxbufsize = 0;
> char *nme = NULL;
> while (...)
> {
> 	...
> 	if (maxbufsize < strlen(tpe) + 4) {
> 		maxbufsize = strlen(tpe) + 4;
> 		nme = nme ? realloc(nme, maxbufsize) : malloc(maxbufsize);
> 	}
> 	...
> 	if (...) {
> 		*nme++ = 'x';
> 		...
> 	}
> }
> if (nme)
> 	free(nme);
> ...
> ========
> 
> IMHO does not work, since the nme++ changes nme, causing later realloc(nme,
> maxbufsize) and/or free(nme) to "behave strangly" --- or simply segfault ...
> 
> Stefan
> 
> 
> On Wed, May 02, 2007 at 09:39:32PM +0000, Sjoerd Mullender wrote:
> > Update of /cvsroot/monetdb/pathfinder/compiler/mil
> > In directory sc8-pr-cvs16:/tmp/cvs-serv18640
> > 
> > Modified Files:
> > 	milprint_summer.c 
> > Log Message:
> > Fix bug introduced by replacing call to alloca.
> > 
> > Index: milprint_summer.c
> > ===================================================================
> > RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/milprint_summer.c,v
> > retrieving revision 1.371
> > retrieving revision 1.372
> > diff -u -d -r1.371 -r1.372
> > --- milprint_summer.c	2 May 2007 21:15:18 -0000	1.371
> > +++ milprint_summer.c	2 May 2007 21:39:30 -0000	1.372
> > @@ -11142,17 +11142,17 @@
> >          /* initialize function variables */
> >          /* ============================= */
> >          size_t maxbufsize = 0;
> > -        char *buf = NULL;
> > +        char *nme = NULL;
> >          while (args->kind != c_nil)
> >          {
> >              /* get the type name, and assure there *is* a namespace */ 
> >              char *tpe = PFty_str(TY(LR(args)));
> > -            char *nme;
> > +            char *buf;
> >              if (maxbufsize < strlen(tpe) + 4) {
> >                  maxbufsize = strlen(tpe) + 4;
> > -                buf = buf ? realloc(buf, maxbufsize) : malloc(maxbufsize);
> > +                nme = nme ? realloc(nme, maxbufsize) : malloc(maxbufsize);
> >              }
> > -            nme = buf;
> > +            buf = nme;
> >              if (strchr(tpe, ':') == NULL)  {
> >                  *nme++ = 'x'; 
> >                  *nme++ = 's'; 
> > @@ -11178,8 +11178,8 @@
> >  
> >              args = R(args);
> >          }
> > -        if (buf)
> > -            free(buf);
> > +        if (nme)
> > +            free(nme);
> >          /* create the full signature that also is a valid MIL identifier */
> >          c->sem.fun->sig = PFmalloc(12+3*(strlen(sig)+strlen(p)));
> >  
> > 
> > 
> > -------------------------------------------------------------------------
> > This SF.net email is sponsored by DB2 Express
> > Download DB2 Express C - the FREE version of DB2 express and take
> > control of your XML. No limits. Just data. Click to get it now.
> > http://sourceforge.net/powerbar/db2/
> > _______________________________________________
> > Monetdb-pf-checkins mailing list
> > Monetdb-pf-checkins at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins
> > 
> 
> -- 
> | Dr. Stefan Manegold | mailto:Stefan.Manegold at cwi.nl |
> | CWI,  P.O.Box 94079 | http://www.cwi.nl/~manegold/  |
> | 1090 GB Amsterdam   | Tel.: +31 (20) 592-4212       |
> | The Netherlands     | Fax : +31 (20) 592-4312       |

-- 
| Dr. Stefan Manegold | mailto:Stefan.Manegold at cwi.nl |
| CWI,  P.O.Box 94079 | http://www.cwi.nl/~manegold/  |
| 1090 GB Amsterdam   | Tel.: +31 (20) 592-4212       |
| The Netherlands     | Fax : +31 (20) 592-4312       |




More information about the developers-list mailing list