[Scummvm-cvs-logs] SF.net SVN: scummvm:[41469] scummvm/branches/gsoc2009-draci/engines/draci/ font.cpp
dkasak13 at users.sourceforge.net
dkasak13 at users.sourceforge.net
Fri Jun 12 11:52:35 CEST 2009
Revision: 41469
http://scummvm.svn.sourceforge.net/scummvm/?rev=41469&view=rev
Author: dkasak13
Date: 2009-06-12 09:52:35 +0000 (Fri, 12 Jun 2009)
Log Message:
-----------
Made the DraciFont::freeFont() method safe to call in any circumstance by making it check for NULL pointers itself to prevent double free / corruption. This also fixes a potential bug in the destructor.
Modified Paths:
--------------
scummvm/branches/gsoc2009-draci/engines/draci/font.cpp
Modified: scummvm/branches/gsoc2009-draci/engines/draci/font.cpp
===================================================================
--- scummvm/branches/gsoc2009-draci/engines/draci/font.cpp 2009-06-12 09:49:38 UTC (rev 41468)
+++ scummvm/branches/gsoc2009-draci/engines/draci/font.cpp 2009-06-12 09:52:35 UTC (rev 41469)
@@ -59,10 +59,8 @@
bool DraciFont::setFont(Common::String &filename) {
- // If there is a font already loaded, free it
- if (_charData) {
- freeFont();
- }
+ // Free previously loaded font (if any)
+ freeFont();
Common::File f;
@@ -98,8 +96,11 @@
}
void DraciFont::freeFont() {
- delete[] _charWidths;
- delete[] _charData;
+ // If there is a font already loaded, free it
+ if (_charData) {
+ delete[] _charWidths;
+ delete[] _charData;
+ }
}
uint8 DraciFont::getCharWidth(uint8 chr) const {
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