Changeset: 5b924f16f424 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5b924f16f424
Modified Files:
        common/stream/stream.c
Branch: Jul2012
Log Message:

Make sure memcpy cannot be passed a NULL pointer.
Found by Coverity.


diffs (15 lines):

diff --git a/common/stream/stream.c b/common/stream/stream.c
--- a/common/stream/stream.c
+++ b/common/stream/stream.c
@@ -1202,8 +1202,10 @@ write_callback(char *buffer, size_t size
        struct curl_data *c = (struct curl_data *) s->stream_data.p;
 
        size *= nitems;
+       if (size == 0)          /* unlikely */
+               return 0;
        /* allocate a buffer if we don't have one yet */
-       if (c->buffer == NULL && size != 0) {
+       if (c->buffer == NULL) {
                /* BLOCK_CURL had better be a power of 2! */
                c->maxsize = (size + BLOCK_CURL - 1) & ~(BLOCK_CURL - 1);
                if ((c->buffer = malloc(c->maxsize)) == NULL)
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to