diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-12-27 19:47:33 +0000 |
---|---|---|
committer | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2004-12-27 19:47:33 +0000 |
commit | 005478ea0c40d2deea4265f6541f675e78de7dd9 (patch) | |
tree | 335491dfda8d0abb537d076b3fc0d81a360d5d36 /libaf | |
parent | 91aae0d5386829c4ae7442aed677506cd92f0247 (diff) |
ensure af_fmt2str always return a 0 terminated string
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14257 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libaf')
-rw-r--r-- | libaf/af_format.c | 5 |
1 files changed, 5 insertions, 0 deletions
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; } |