From 93ff6fa2b04be057f5c5f01efbe13b0806d9b60c Mon Sep 17 00:00:00 2001 From: Vasily Redkin Date: Tue, 18 Jun 2013 14:03:07 +0400 Subject: [PATCH] Fix .m3u playlist http downloading --- src/m3u/m3u.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/m3u/m3u.c b/src/m3u/m3u.c index b0576ff..562c665 100644 --- a/src/m3u/m3u.c +++ b/src/m3u/m3u.c @@ -41,12 +41,22 @@ static void strip_char (char * text, char c) static char * read_win_text (VFSFile * file) { - int64_t size = vfs_fsize (file); - if (size < 1) - return NULL; + int64_t size = 0; + int64_t alloc = vfs_fsize (file); + char * raw = NULL; + if (alloc < 1) + alloc = 8191; - char * raw = malloc (size + 1); - size = vfs_fread (raw, 1, size, file); + for (;;) + { + int64_t rd; + raw = realloc (raw, alloc + 1); + rd = vfs_fread (raw + size, 1, alloc - size, file); + if (! rd) + break; + size += rd; + alloc += rd; + } raw[size] = 0; strip_char (raw, '\r'); -- 1.7.10.4