diff libmpdemux/stream.c @ 18558:4928dd61f136

Fix potential integer overflows in memory allocation. Patch by Rich and me
author rtogni
date Sun, 04 Jun 2006 22:41:27 +0000
parents f72bc5754209
children cb7da1894b00
line wrap: on
line diff
--- a/libmpdemux/stream.c	Fri Jun 02 11:31:42 2006 +0000
+++ b/libmpdemux/stream.c	Sun Jun 04 22:41:27 2006 +0000
@@ -354,7 +354,11 @@
 }
 
 stream_t* new_memory_stream(unsigned char* data,int len){
-  stream_t *s=malloc(sizeof(stream_t)+len);
+  stream_t *s;
+
+  if(len < 0)
+    return NULL;
+  s=malloc(sizeof(stream_t)+len);
   memset(s,0,sizeof(stream_t));
   s->fd=-1;
   s->type=STREAMTYPE_MEMORY;