[MPlayer-cvslog] r36247 - trunk/libmenu/menu_txt.c

reimar subversion at mplayerhq.hu
Tue May 7 22:39:16 CEST 2013


Author: reimar
Date: Tue May  7 22:39:16 2013
New Revision: 36247

Log:
Ensure 0-termination.

Modified:
   trunk/libmenu/menu_txt.c

Modified: trunk/libmenu/menu_txt.c
==============================================================================
--- trunk/libmenu/menu_txt.c	Tue May  7 22:39:15 2013	(r36246)
+++ trunk/libmenu/menu_txt.c	Tue May  7 22:39:16 2013	(r36247)
@@ -153,6 +153,8 @@ static int open_txt(menu_t* menu, char* 
 
   while(1) {
     r = fread(buf+pos,1,BUF_SIZE-pos-1,fd);
+    if (r > 0) pos += r;
+    buf[pos] = '\0';
     if(r <= 0) {
       if(pos > 0) {
 	mpriv->lines = realloc(mpriv->lines,(mpriv->num_lines + 1)*sizeof(char*));
@@ -162,8 +164,6 @@ static int open_txt(menu_t* menu, char* 
       fclose(fd);
       break;
     }
-    pos += r;
-    buf[pos] = '\0';
 
     while((l = strchr(buf,'\n')) != NULL) {
       s = l-buf;


More information about the MPlayer-cvslog mailing list