changeset 25777:1d16b891d440

Cached file must be 0-terminated since we use string processing functions on it
author reimar
date Sat, 19 Jan 2008 16:41:35 +0000
parents cf1d3164d30c
children 15c5da485a77
files stream/stream_cddb.c
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/stream/stream_cddb.c	Sat Jan 19 16:33:06 2008 +0000
+++ b/stream/stream_cddb.c	Sat Jan 19 16:41:35 2008 +0000
@@ -338,10 +338,10 @@
 		perror("fstat");
 		file_size = 4096;
 	} else {
-		file_size = stats.st_size;
+		file_size = stats.st_size < UINT_MAX ? stats.st_size : UINT_MAX - 1;
 	}
 	
-	cddb_data->xmcd_file = malloc(file_size);
+	cddb_data->xmcd_file = malloc(file_size+1);
 	if( cddb_data->xmcd_file==NULL ) {
 		mp_msg(MSGT_DEMUX, MSGL_ERR, MSGTR_MemAllocFailed);
 		close(file_fd);
@@ -353,6 +353,7 @@
 		close(file_fd);
 		return -1;
 	}
+	cddb_data->xmcd_file[cddb_data->xmcd_file_size] = 0;
 	
 	close(file_fd);