From: <ave...@us...> - 2009-08-06 22:01:16
|
Revision: 6823 http://gemrb.svn.sourceforge.net/gemrb/?rev=6823&view=rev Author: avenger_teambg Date: 2009-08-06 22:01:10 +0000 (Thu, 06 Aug 2009) Log Message: ----------- make sure the buffer is always zero terminated and its size is 'max' without the zero terminator Modified Paths: -------------- gemrb/trunk/gemrb/plugins/Core/TextEdit.cpp Modified: gemrb/trunk/gemrb/plugins/Core/TextEdit.cpp =================================================================== --- gemrb/trunk/gemrb/plugins/Core/TextEdit.cpp 2009-08-06 21:54:38 UTC (rev 6822) +++ gemrb/trunk/gemrb/plugins/Core/TextEdit.cpp 2009-08-06 22:01:10 UTC (rev 6823) @@ -180,6 +180,7 @@ int TextEdit::SetText(const char* string, int /*pos*/) { strncpy( ( char * ) Buffer, string, max ); + Buffer[max]=0; CurPos = (ieWord) strlen((char *) Buffer); if (Owner) { Owner->Invalidate(); @@ -191,9 +192,9 @@ { if(buflen<1) return; if(buflen!=max) { - Buffer = (unsigned char *) realloc(Buffer, buflen); + Buffer = (unsigned char *) realloc(Buffer, buflen+1); max=(ieWord) buflen; - Buffer[max-1]=0; + Buffer[max]=0; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |