Changeset: 4d589c243ae2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/4d589c243ae2
Modified Files:
monetdb5/modules/atoms/str.c
Branch: Jan2022
Log Message:
Merged with Jul2021
diffs (35 lines):
diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c
--- a/monetdb5/modules/atoms/str.c
+++ b/monetdb5/modules/atoms/str.c
@@ -3225,12 +3225,11 @@ convertCase(BAT *from, BAT *to, str *buf
const Hash *h = from->thash;
const int *restrict fromb = (const int *restrict) from->theap->base;
const int *restrict tob = (const int *restrict) to->theap->base;
- size_t nextlen = len + 1;
/* the from and to bats are not views */
assert(from->tbaseoff == 0);
assert(to->tbaseoff == 0);
- CHECK_STR_BUFFER_LENGTH(buf, buflen, nextlen, malfunc);
+ CHECK_STR_BUFFER_LENGTH(buf, buflen, len + 1, malfunc);
dst = *buf;
while (src < end) {
int c;
@@ -3263,7 +3262,16 @@ convertCase(BAT *from, BAT *to, str *buf
size_t off = dst - *buf;
size_t nextlen = (len += 4 + (end - src)) + 1;
- CHECK_STR_BUFFER_LENGTH(buf, buflen, nextlen, malfunc);
+ /* Don't use CHECK_STR_BUFFER_LENGTH here, because it
+ * does GDKmalloc instead of GDKrealloc and data could
be lost */
+ if (nextlen > *buflen) {
+ size_t newlen = ((nextlen + 1023) & ~1023); /*
align to a multiple of 1024 bytes */
+ str newbuf = GDKrealloc(*buf, newlen);
+ if (!newbuf)
+ throw(MAL, malfunc, SQLSTATE(HY013)
MAL_MALLOC_FAIL);
+ *buf = newbuf;
+ *buflen = newlen;
+ }
dst = *buf + off;
}
UTF8_PUTCHAR(c, dst);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list