[NUT-devel] [nut]: r146 - trunk/libnut/demuxer.c

ods15 subversion at mplayerhq.hu
Sat Sep 23 21:31:20 CEST 2006


Author: ods15
Date: Sat Sep 23 21:31:20 2006
New Revision: 146

Modified:
   trunk/libnut/demuxer.c

Log:
more malloc paranoia, in buffer read


Modified: trunk/libnut/demuxer.c
==============================================================================
--- trunk/libnut/demuxer.c	(original)
+++ trunk/libnut/demuxer.c	Sat Sep 23 21:31:20 2006
@@ -29,8 +29,11 @@
 	if (bc->read_len - pos < amount && !bc->is_mem) {
 		amount += 10; // ### + PREALLOC_SIZE ?
 		if (bc->write_len - pos < amount) {
-			bc->write_len = amount + pos + PREALLOC_SIZE;
-			bc->buf = bc->alloc->realloc(bc->buf, bc->write_len);
+			int new_len = amount + pos + PREALLOC_SIZE;
+			uint8_t * buf = bc->alloc->realloc(bc->buf, new_len);
+			if (!buf) return 0;
+			bc->write_len = new_len;
+			bc->buf = buf;
 			bc->buf_ptr = bc->buf + pos;
 		}
 		bc->read_len += bc->isc.read(bc->isc.priv, amount - (bc->read_len - pos), bc->buf + bc->read_len);



More information about the NUT-devel mailing list