Permalink
Browse files

GRAPHICS: Remove use of nonstandard strdup API & fix mismatched mallo…

…c/delete
  • Loading branch information...
csnover authored and sev- committed Dec 5, 2017
1 parent a726b3b commit c544d8050cb59e3f07062d2de12dc0faff04d436
Showing with 11 additions and 2 deletions.
  1. +11 −2 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) {

0 comments on commit c544d80

Please sign in to comment.