[Mplayer-cvslog] CVS: main playtree.c,1.13,1.14 playtreeparser.c,1.8,1.9 asxparser.c,1.4,1.5

Alban Bedel CVS albeu at mplayerhq.hu
Tue Apr 23 22:06:04 CEST 2002


Update of /cvsroot/mplayer/main
In directory mail:/var/tmp.root/cvs-serv21371

Modified Files:
	playtree.c playtreeparser.c asxparser.c 
Log Message:
Portability fix with realloc


Index: playtree.c
===================================================================
RCS file: /cvsroot/mplayer/main/playtree.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- playtree.c	16 Apr 2002 17:41:28 -0000	1.13
+++ playtree.c	23 Apr 2002 20:06:00 -0000	1.14
@@ -605,7 +605,12 @@
 
   iter->stack_size--;
   iter->loop = iter->status_stack[iter->stack_size];
-  iter->status_stack = (int*)realloc(iter->status_stack,iter->stack_size*sizeof(int));
+  if(iter->stack_size > 0)
+    iter->status_stack = (int*)realloc(iter->status_stack,iter->stack_size*sizeof(int));
+  else {
+    free(iter->status_stack);
+    iter->status_stack = NULL;
+  }
   if(iter->stack_size > 0 && iter->status_stack == NULL) {
     mp_msg(MSGT_PLAYTREE,MSGL_ERR,"Can't allocate %d bytes of memory\n",iter->stack_size*sizeof(char*));
     return PLAY_TREE_ITER_ERROR;

Index: playtreeparser.c
===================================================================
RCS file: /cvsroot/mplayer/main/playtreeparser.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- playtreeparser.c	22 Apr 2002 18:42:42 -0000	1.8
+++ playtreeparser.c	23 Apr 2002 20:06:00 -0000	1.9
@@ -49,7 +49,7 @@
     p->iter = p->buffer;
   }
 
-  if(p->stream->eof && p->buffer_end == 0)
+  if(p->stream->eof && (p->buffer_end == 0 || p->iter[0] == '\0'))
     return NULL;
     
   while(1) {
@@ -83,12 +83,14 @@
   }
 
   line_end = ((*(end-1)) == '\r') ? end-1 : end;
-  p->line = (char*)realloc(p->line,line_end - p->iter+1);
-  if(!p->line)
+  if(line_end - p->iter >= 0)
+    p->line = (char*)realloc(p->line,line_end - p->iter+1);
+  else
     return NULL;
-  strncpy(p->line,p->iter,line_end - p->iter);
+  if(line_end - p->iter > 0)
+    strncpy(p->line,p->iter,line_end - p->iter);
   p->line[line_end - p->iter] = '\0';
-  if(end != '\0')
+  if(end[0] != '\0')
     end++;
 
   if(!p->keep) {

Index: asxparser.c
===================================================================
RCS file: /cvsroot/mplayer/main/asxparser.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- asxparser.c	23 Feb 2002 21:11:01 -0000	1.4
+++ asxparser.c	23 Apr 2002 20:06:00 -0000	1.5
@@ -264,7 +264,12 @@
       if( i < parser->ret_stack_size)	
 	memmove(parser->ret_stack,parser->ret_stack+i, (parser->ret_stack_size - i)*sizeof(ASX_LineSave_t));
       parser->ret_stack_size -= i;
-      parser->ret_stack = (ASX_LineSave_t*)realloc(parser->ret_stack,parser->ret_stack_size*sizeof(ASX_LineSave_t));      
+      if(parser->ret_stack_size > 0)
+	parser->ret_stack = (ASX_LineSave_t*)realloc(parser->ret_stack,parser->ret_stack_size*sizeof(ASX_LineSave_t));
+      else {
+	free(parser->ret_stack);
+	parser->ret_stack = NULL;
+      }
     }
   }
 




More information about the MPlayer-cvslog mailing list