diff --git a/src/hb-common.cc b/src/hb-common.cc index 39006237a0c8fa164e792cdefcb3d0c4925a775f..daba0c553cce3882ad834c0cc18d9da68d3279ad 100644 --- a/src/hb-common.cc +++ b/src/hb-common.cc @@ -221,7 +221,13 @@ struct hb_language_item_t { } inline hb_language_item_t & operator = (const char *s) { - lang = (hb_language_t) strdup (s); + /* If a custom allocated is used calling strdup() pairs + badly with a call to the custom free() in finish() below. + Therefore don't call strdup(), implement its behavior. + */ + size_t len = strlen(s) + 1; + lang = (hb_language_t) malloc(len); + memcpy((unsigned char *) lang, s, len); for (unsigned char *p = (unsigned char *) lang; *p; p++) *p = canon_map[*p]; diff --git a/src/hb-private.hh b/src/hb-private.hh index 666af6260b41b81057f2b1986a12b3d535c4c456..3595edee382485dd4b4087e63fc27a9af1c58fbd 100644 --- a/src/hb-private.hh +++ b/src/hb-private.hh @@ -168,7 +168,6 @@ extern "C" void hb_free_impl(void *ptr); # if defined(_WIN32_WCE) /* Some things not defined on Windows CE. */ -# define strdup _strdup # define vsnprintf _vsnprintf # define getenv(Name) NULL # if _WIN32_WCE < 0x800 @@ -180,9 +179,6 @@ static int errno = 0; /* Use something better? */ # endif # if defined(_MSC_VER) && _MSC_VER < 1900 # define snprintf _snprintf -# elif defined(_MSC_VER) && _MSC_VER >= 1900 -# /* Covers VC++ Error for strdup being a deprecated POSIX name and to instead use _strdup instead */ -# define strdup _strdup # endif #endif