Update of /cvsroot/monetdb/MonetDB/src/common
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv15215/src/common
Modified Files:
monet_options.mx stream.mx
Log Message:
making klocwork happier..
klocwork is a kind of improved lint, ie. 'static c program analyses'
To find memory problems, out of bounds access, security problems etc
(first round was about 700 errors, now down to 295 (of which the larger part
are false possitives)
Index: monet_options.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB/src/common/monet_options.mx,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- monet_options.mx 11 Jan 2008 10:36:59 -0000 1.23
+++ monet_options.mx 1 Feb 2008 12:21:30 -0000 1.24
@@ -194,8 +194,8 @@
t = malloc((n = n - 14 + strlen(p)));
*q = 0;
snprintf(t, n, "%s%s%s", s, p, q + 14);
- free(s);
q = t + (q-s);
+ free(s);
s = t;
} else if (strncmp(q, "${prefix}", 9) == 0) {
char *p = mo_find_option(set, setlen, "prefix");
@@ -206,8 +206,8 @@
t = malloc((n = n - 9 + strlen(p)));
*q = 0;
snprintf(t, n, "%s%s%s", s, p, q + 9);
- free(s);
q = t + (q-s);
+ free(s);
s = t;
} else
q++;
@@ -224,8 +224,8 @@
t = malloc((n = n - 13 + strlen(p)));
*q = 0;
snprintf(t, n, "%s%s%s", s, p, q + 13);
- free(s);
q = t + (q-s);
+ free(s);
s = t;
} else if (strncmp(q, "%prefix%", 8) == 0) {
char *p = mo_find_option(set, setlen, "prefix");
@@ -236,8 +236,8 @@
t = malloc((n = n - 8 + strlen(p)));
*q = 0;
snprintf(t, n, "%s%s%s", s, p, q + 8);
- free(s);
q = t + (q-s);
+ free(s);
s = t;
} else
q++;
Index: stream.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB/src/common/stream.mx,v
retrieving revision 1.156
retrieving revision 1.157
diff -u -d -r1.156 -r1.157
--- stream.mx 11 Jan 2008 10:36:59 -0000 1.156
+++ stream.mx 1 Feb 2008 12:21:31 -0000 1.157
@@ -1708,15 +1708,16 @@
udp_write(stream *s, const void *buf, size_t elmsize, size_t cnt)
{
ssize_t res = 0, size = elmsize * cnt;
- udp_stream *udp = s->stream_data.p;
- int addrlen = sizeof(udp->addr);
+ udp_stream *udp;
+ int addrlen;
if (!s || s->errnr)
return -1;
if (size == 0 || elmsize == 0)
return cnt;
-
+ udp = s->stream_data.p;
+ addrlen = sizeof(udp->addr);
errno = 0;
if ((res = sendto(udp->s, buf,
#ifdef NATIVE_WIN32
@@ -1737,11 +1738,12 @@
ssize_t res = 0, size = elmsize * cnt;
struct sockaddr_in from;
socklen_t fromlen = sizeof(struct sockaddr_in);
- udp_stream *udp = s->stream_data.p;
+ udp_stream *udp;
if (!s || s->errnr)
return(-1);
+ udp = s->stream_data.p;
errno = 0;
if ((res = recvfrom(udp->s, buf,
#ifdef NATIVE_WIN32
@@ -2509,10 +2511,11 @@
char *
buffer_get_buf(buffer *b)
{
- char *r = b->buf;
+ char *r;
if (b->pos == b->len && (b->buf = realloc(b->buf, b->len+1)) == NULL)
return NULL;
+ r = b->buf;
r[b->pos] = '\0';
b->buf = malloc(b->len);
b->len = b->buf ? b->len : 0;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins