From c544d8050cb59e3f07062d2de12dc0faff04d436 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Mon, 4 Dec 2017 20:27:29 -0600 Subject: GRAPHICS: Remove use of nonstandard strdup API & fix mismatched malloc/delete --- graphics/fonts/bdf.cpp | 13 +++++++++++-- 1 file 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) { -- cgit v1.2.3