[uim-commit] r2589 - branches/r5rs/sigscheme
kzk at freedesktop.org
kzk at freedesktop.org
Thu Dec 15 18:17:09 PST 2005
Author: kzk
Date: 2005-12-15 18:17:03 -0800 (Thu, 15 Dec 2005)
New Revision: 2589
Modified:
branches/r5rs/sigscheme/strport.c
Log:
* sigscheme/strport.c
- (ostrport_append): fix invalid memory allocation size when
port->buf_size is zero, and not to access NULL[port->cur]
when new_str is NULL.
Modified: branches/r5rs/sigscheme/strport.c
===================================================================
--- branches/r5rs/sigscheme/strport.c 2005-12-15 18:51:42 UTC (rev 2588)
+++ branches/r5rs/sigscheme/strport.c 2005-12-16 02:17:03 UTC (rev 2589)
@@ -412,10 +412,13 @@
static size_t
ostrport_append(ScmOutputStrPort *port, size_t len, const char *str)
{
- char *new_str;
+ char *new_str = NULL;
/* extend the buffer */
if (port->buf_size - port->cur < len + sizeof((char)'\0')) {
+ if (port->buf_size == 0)
+ port->buf_size += sizeof((char)'\0');
+
port->buf_size += len;
new_str = realloc(port->str, port->buf_size);
if (!new_str)
@@ -425,7 +428,7 @@
memcpy(port->str + port->cur, str, len);
port->cur += len;
- new_str[port->cur] = '\0';
+ port->str[port->cur] = '\0';
return len + sizeof((char)'\0');
}
More information about the uim-commit
mailing list