diff options
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) { |