Changeset: f694b42ec70e for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f694b42ec70e
Modified Files:
monetdb5/modules/mal/tablet.c
Branch: Oct2012
Log Message:
Fix an off-by-one error.
This should fix bug 3161.
The problem was that the code checked whether the data would fit the
allocated space, and if it didn't, it would allocate more. So far so
good. But if the data fits exactly, the code would then copy one too
few characters. We now extend the buffer if the data fits exactly.
Note that fitting exactly is here defined as fits without the usual
NUL byte at the end of the string, so we needed to extend for that
anyway.
This only showed up on Windows because BUFSIZ is significantly smaller
on Windows than on Linux.
diffs (12 lines):
diff --git a/monetdb5/modules/mal/tablet.c b/monetdb5/modules/mal/tablet.c
--- a/monetdb5/modules/mal/tablet.c
+++ b/monetdb5/modules/mal/tablet.c
@@ -665,7 +665,7 @@ output_line_dense(char **buf, int *len,
l = f->tostr(f->extra, localbuf, locallen,
f->adt, p);
p = *localbuf;
}
- if (fill + l + f->seplen > *len) {
+ if (fill + l + f->seplen >= *len) {
/* extend the buffer */
*buf = (char *) GDKrealloc(*buf, fill + l +
f->seplen + BUFSIZ);
*len = fill + l + f->seplen + BUFSIZ;
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list