From 005478ea0c40d2deea4265f6541f675e78de7dd9 Mon Sep 17 00:00:00 2001 From: reimar Date: Mon, 27 Dec 2004 19:47:33 +0000 Subject: ensure af_fmt2str always return a 0 terminated string git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14257 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libaf/af_format.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libaf/af_format.c b/libaf/af_format.c index 68c0a647f3..f39022f1f5 100644 --- a/libaf/af_format.c +++ b/libaf/af_format.c @@ -110,6 +110,10 @@ char* af_fmt2str(int format, char* str, int size) { int i=0; + if (size < 1) + return NULL; + size--; // reserve one for terminating 0 + // Endianess if(AF_FORMAT_LE == (format & AF_FORMAT_END_MASK)) i+=snprintf(str,size-i,"little endian "); @@ -147,6 +151,7 @@ char* af_fmt2str(int format, char* str, int size) i+=snprintf(&str[i],size-i,"int "); } } + str[i] = 0; // make sure it is 0 terminated. return str; } -- cgit v1.2.3