[Scummvm-cvs-logs] SF.net SVN: scummvm:[54964] scummvm/trunk/graphics/font.cpp
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Sun Dec 19 17:16:25 CET 2010
Revision: 54964
http://scummvm.svn.sourceforge.net/scummvm/?rev=54964&view=rev
Author: thebluegr
Date: 2010-12-19 16:16:25 +0000 (Sun, 19 Dec 2010)
Log Message:
-----------
GRAPHICS: Fixed code analysis warnings (bug #3087917)
Modified Paths:
--------------
scummvm/trunk/graphics/font.cpp
Modified: scummvm/trunk/graphics/font.cpp
===================================================================
--- scummvm/trunk/graphics/font.cpp 2010-12-19 16:07:03 UTC (rev 54963)
+++ scummvm/trunk/graphics/font.cpp 2010-12-19 16:16:25 UTC (rev 54964)
@@ -224,6 +224,11 @@
warning("Error: EOF on file");
return 0;
}
+
+ /* note: the way sscanf is used here ensures that a terminating null
+ character is automatically added. Refer to:
+ http://pubs.opengroup.org/onlinepubs/009695399/functions/fscanf.html */
+
if (isprefix(buf, "FONT ")) { /* not required*/
if (sscanf(buf, "FONT %[^\n]", facename) != 1) {
warning("Error: bad 'FONT'");
@@ -506,7 +511,11 @@
/* reallocate bits array to actual bits used*/
if (ofs < pf->bits_size) {
- pf->bits = (bitmap_t *)realloc(pf->bits, ofs * sizeof(bitmap_t));
+ bitmap_t *tmp = (bitmap_t *)realloc(pf->bits, ofs * sizeof(bitmap_t));
+ if (tmp != NULL || ofs == 0)
+ pf->bits = tmp;
+ else
+ error("bdf_read_bitmaps: Error while reallocating memory");
pf->bits_size = ofs;
}
else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list