[prev in list] [next in list] [prev in thread] [next in thread] 

List:       monetdb-checkins
Subject:    [Monetdb-checkins] MonetDB/src/common stream.mx,,1.182,1.183
From:       Stefan Manegold <stmane () users ! sourceforge ! net>
Date:       2009-10-30 21:39:45
Message-ID: E1N3zCD-0002OL-Hv () 23jxhf1 ! ch3 ! sourceforge ! com
[Download RAW message or body]

Update of /cvsroot/monetdb/MonetDB/src/common
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv9187/src/common

Modified Files:
	stream.mx 
Log Message:
propagated changes of Friday Oct 30 2009
from the Nov2009 branch to the development trunk

  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2009/10/30 - stmane: src/common/stream.mx,1.181.2.2
  propagated changes of Friday Oct 30 2009
  from the Aug2009 branch to the Nov2009 branch
  
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    2009/10/30 - sjoerd: src/common/stream.mx,1.177.4.4
    If we can't allocate both needed structures/buffers, don't allocate anything.
    Also, no asserts after malloc failures: that's not very friendly.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    2009/10/30 - sjoerd: src/common/stream.mx,1.177.4.5
    Added some asserts to help find instances where we're trying to read
    from a stream after the stream suffered a problem with a failed
    realloc.  This helps finding places where the server crashes after an
    out-of-memory situation.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


Index: stream.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB/src/common/stream.mx,v
retrieving revision 1.182
retrieving revision 1.183
diff -u -d -r1.182 -r1.183
--- stream.mx	23 Oct 2009 22:41:15 -0000	1.182
+++ stream.mx	30 Oct 2009 21:39:43 -0000	1.183
@@ -2238,6 +2238,10 @@
 	s->close = ic_close;
 	s->flush = ic_flush;
 	s->stream_data.p = malloc(sizeof(struct icstream));
+	if (s->stream_data.p == NULL) {
+		stream_destroy(s);
+		return NULL;
+	}
 	ic = (struct icstream *) s->stream_data.p;
 	ic->cd = cd;
 	ic->s = ss;
@@ -2301,7 +2305,11 @@
 		return NULL;
 	b->pos = 0;
 	b->buf = malloc(size);
-	b->len = b->buf ? size : 0;
+	if (b->buf == NULL) {
+		free(b);
+		return NULL;
+	}
+	b->len = size;
 	return b;
 }
 
@@ -3013,7 +3021,6 @@
 		if (bf != buf)
 			free(bf);
 		bf = malloc(bfsz);
-		assert(bf != NULL);
 		if (bf == NULL) {
 			s->errnr = WRITE_ERROR;
 			return -1;
@@ -3041,7 +3048,11 @@
 		size = BUFSIZ;
 	b->s = s;
 	b->buf = malloc(size + 1 + 1);
-	b->size = b->buf ? size : 0;
+	if (b->buf == NULL) {
+		free(b);
+		return NULL;
+	}
+	b->size = size;
 	b->pos = 0;
 	b->len = 0;
 	b->eof = 0;
@@ -3064,6 +3075,7 @@
 		s->pos = 0;
 	}
 
+	assert(s->buf != NULL);
 	if (s->len == s->size && (s->buf = realloc(s->buf, (s->size <<= 1) + 1)) == NULL) {
 		s->size = 0;
 		s->len = 0;
@@ -3111,6 +3123,7 @@
 		s->pos = 0;
 	}
 
+	assert(s->buf != NULL);
 	if (s->len == s->size && (s->buf = realloc(s->buf, (s->size <<= 1) + 1)) == NULL) {
 		s->size = 0;
 		s->len = 0;


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Monetdb-checkins mailing list
Monetdb-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic