[MPlayer-cvslog] r28217 - trunk/playtreeparser.c

reimar subversion at mplayerhq.hu
Thu Jan 1 10:35:30 CET 2009


Author: reimar
Date: Thu Jan  1 10:35:25 2009
New Revision: 28217

Log:
Add asserts to detect when assumptions for play_tree_parser_get_line
fail (mostly due to parsers using it incorrectly).

Modified:
   trunk/playtreeparser.c

Modified: trunk/playtreeparser.c
==============================================================================
--- trunk/playtreeparser.c	Wed Dec 31 15:21:50 2008	(r28216)
+++ trunk/playtreeparser.c	Thu Jan  1 10:35:25 2009	(r28217)
@@ -6,9 +6,7 @@
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#ifdef MP_DEBUG
 #include <assert.h>
-#endif
 #include <errno.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -61,6 +59,8 @@ play_tree_parser_get_line(play_tree_pars
   if(p->stream->eof && (p->buffer_end == 0 || p->iter[0] == '\0'))
     return NULL;
     
+  assert(p->buffer_end < p->buffer_size);
+  assert(!p->buffer[p->buffer_end]);
   while(1) {
 
     if(resize) {
@@ -75,10 +75,12 @@ play_tree_parser_get_line(play_tree_pars
       r = stream_read(p->stream,p->buffer + p->buffer_end,p->buffer_size - p->buffer_end - 1);
       if(r > 0) {
 	p->buffer_end += r;
+	assert(p->buffer_end < p->buffer_size);
 	p->buffer[p->buffer_end] = '\0';
 	while(strlen(p->buffer + p->buffer_end - r) != r)
 	  p->buffer[p->buffer_end - r + strlen(p->buffer + p->buffer_end - r)] = '\n';
       }
+      assert(!p->buffer[p->buffer_end]);
     }
     
     end = strchr(p->iter,'\n');



More information about the MPlayer-cvslog mailing list