Mercurial > mplayer.hg
changeset 36151:63bc09af21f4
Ensure 0-termination.
author | reimar |
---|---|
date | Tue, 07 May 2013 20:39:16 +0000 |
parents | 98eb9f802619 |
children | c3b4a1b48c7d |
files | libmenu/menu_txt.c |
diffstat | 1 files changed, 2 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libmenu/menu_txt.c Tue May 07 20:39:15 2013 +0000 +++ b/libmenu/menu_txt.c Tue May 07 20:39:16 2013 +0000 @@ -153,6 +153,8 @@ 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 @@ fclose(fd); break; } - pos += r; - buf[pos] = '\0'; while((l = strchr(buf,'\n')) != NULL) { s = l-buf;