Skip to content

Commit

Permalink
[fix] patch for #45
Browse files Browse the repository at this point in the history
  • Loading branch information
takkaO committed May 19, 2024
1 parent 5100f1f commit 5331631
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/OpenFontRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,11 +440,11 @@ FT_Error OpenFontRender::loadFont(const unsigned char *data, size_t size, uint8_
* @note Any better solutions are welcome.
*/
FT_Error OpenFontRender::loadFont(const char *fpath, uint8_t target_face_index) {
size_t len = strlen(fpath);
size_t len = strlen(fpath) + 1; // +1 is for NULL character because strlen do not include NULL character

_face_id.filepath = new char[len + 1]; // Release on unloadFont method
_face_id.filepath = new char[len](); // Release on unloadFont method
strncpy(_face_id.filepath, fpath, len);
_face_id.filepath[len] = '\0';
_face_id.filepath[len - 1] = '\0'; // Not required but explicitly stated.

_face_id.face_index = target_face_index;
return loadFont(OFR::FROM_FILE);
Expand Down

0 comments on commit 5331631

Please sign in to comment.