Update of /cvsroot/monetdb/pathfinder/compiler/mil
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv4262/compiler/mil
Modified Files:
mil_opt.c milprint_summer.c
Log Message:
[ 1633232 ] PF: memory reallocation buggy
- fixed PFrealloc so it knows the old region size
Index: mil_opt.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/mil_opt.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- mil_opt.c 13 Mar 2007 13:55:59 -0000 1.27
+++ mil_opt.c 25 May 2007 10:27:39 -0000 1.28
@@ -38,12 +38,12 @@
/* malloc to return result buffers with */
#define EXTERN_MALLOC(n) PFmalloc(n)
-#define EXTERN_REALLOC(p, n) PFrealloc(p, n)
+#define EXTERN_REALLOC(p, o, n) PFrealloc(p, o, n)
#define EXTERN_FREE(p)
/* malloc for internal use in milopt structures */
#define INTERN_MALLOC(n) PFmalloc(n)
-#define INTERN_REALLOC(p, n) PFrealloc(p, n)
+#define INTERN_REALLOC(p, o, n) PFrealloc(p, o, n)
#define INTERN_FREE(p)
opt_name_t name_if, name_else;
@@ -287,9 +287,10 @@
#define APPEND_PUTC(o,sec,c,dst,end)
\
if (((scope<0) | (c!='\n')) || (dst > o->buf[sec] && dst[-1]!='\n')) {
\
if (dst >= end) {
\
+ size_t oldlen = o->len[sec];
\
o->off[sec] = dst - o->buf[sec];
\
o->len[sec] += (o->len[sec]<1024)?1024:o->len[sec];
\
- o->buf[sec] = (char*) EXTERN_REALLOC(o->buf[sec], o->len[sec]);
\
+ o->buf[sec] = (char*) EXTERN_REALLOC(o->buf[sec], oldlen,
o->len[sec]); \
APPEND_INIT(o,sec,dst,end);
\
} *dst++ = c; }
@@ -901,12 +902,13 @@
j = vsnprintf(milbuf, i, format, ap);
va_end (ap);
while (j < 0 || j > i) {
+ int old_i = i;
if (j > 0) /* C99 */
i = j + 1;
else /* old C */
i *= 2;
- milbuf = INTERN_REALLOC(milbuf, i);
+ milbuf = INTERN_REALLOC(milbuf, old_i, i);
if (milbuf == NULL) return -1;
va_start(ap, format);
Index: milprint_summer.c
===================================================================
RCS file: /cvsroot/monetdb/pathfinder/compiler/mil/milprint_summer.c,v
retrieving revision 1.385
retrieving revision 1.386
diff -u -d -r1.385 -r1.386
--- milprint_summer.c 25 May 2007 09:54:36 -0000 1.385
+++ milprint_summer.c 25 May 2007 10:27:40 -0000 1.386
@@ -132,11 +132,12 @@
j = vsnprintf(msg, i, format, ap);
va_end (ap);
while (j < 0 || j > i) {
+ int old_i = i;
if (j > 0) /* C99 */
i = j + 1;
else /* old C */
i *= 2;
- msg = PFrealloc(msg, i);
+ msg = PFrealloc(msg, old_i, i);
va_start(ap, format);
j = vsnprintf(msg, i, format, ap);
va_end (ap);
-------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-pf-checkins