diff options
author | Colin Snover | 2017-12-04 20:27:29 -0600 |
---|---|---|
committer | Eugene Sandulenko | 2018-08-18 16:30:05 +0200 |
commit | c544d8050cb59e3f07062d2de12dc0faff04d436 (patch) | |
tree | 0f8d93dc5adc83ccf3a4072235bd9b81874e72f0 /graphics/fonts | |
parent | a726b3bc896001041e2c73e7090900908349a207 (diff) | |
download | scummvm-rg350-c544d8050cb59e3f07062d2de12dc0faff04d436.tar.gz scummvm-rg350-c544d8050cb59e3f07062d2de12dc0faff04d436.tar.bz2 scummvm-rg350-c544d8050cb59e3f07062d2de12dc0faff04d436.zip |
GRAPHICS: Remove use of nonstandard strdup API & fix mismatched malloc/delete
Diffstat (limited to 'graphics/fonts')
-rw-r--r-- | graphics/fonts/bdf.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/graphics/fonts/bdf.cpp b/graphics/fonts/bdf.cpp index e3c6ee1604..03c1b7b541 100644 --- a/graphics/fonts/bdf.cpp +++ b/graphics/fonts/bdf.cpp @@ -700,6 +700,15 @@ BdfFont *BdfFont::loadFromCache(Common::SeekableReadStream &stream) { return new BdfFont(data, DisposeAfterUse::YES); } +static char *new_strdup(const char *in) { + const size_t len = strlen(in) + 1; + char *out = new char[len]; + if (out) { + strcpy(out, in); + } + return out; +} + BdfFont *BdfFont::scaleFont(BdfFont *src, int newSize) { if (!src) { warning("Empty font reference in scale font"); @@ -725,8 +734,8 @@ BdfFont *BdfFont::scaleFont(BdfFont *src, int newSize) { data.firstCharacter = src->_data.firstCharacter; data.defaultCharacter = src->_data.defaultCharacter; data.numCharacters = src->_data.numCharacters; - data.familyName = strdup(src->_data.familyName); - data.slant = strdup(src->_data.slant); + data.familyName = new_strdup(src->_data.familyName); + data.slant = new_strdup(src->_data.slant); BdfBoundingBox *boxes = new BdfBoundingBox[data.numCharacters]; for (int i = 0; i < data.numCharacters; ++i) { |