ensure af_fmt2str always return a 0 terminated string

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@14257 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2004-12-27 19:47:33 +00:00
parent 91aae0d538
commit 005478ea0c
1 changed files with 5 additions and 0 deletions

View File

@ -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;
}