dtinfo: Fix a segmentation fault.

The return value from CanvasRenderer::_dofont is a pointer. It will be passed
to the free function. Ensure that pointer always points to a dynamically
allocated memory to avoid segmentation faults.
This commit is contained in:
Liang Chang
2021-05-04 03:00:57 +08:00
committed by Jon Trulson
parent 35c35d2b3c
commit 3909c8dbcc

View File

@@ -621,7 +621,7 @@ CanvasRenderer::_dofont(const FeatureSet &fs, Symbol** symbols)
// if we still can't find one go with whatever. // if we still can't find one go with whatever.
else { else {
xlfd = (char*)"-*-*-*-*-*-*-*-*-*-*-*-*-*"; xlfd = strdup("-*-*-*-*-*-*-*-*-*-*-*-*-*");
} }
#ifdef FONT_DEBUG #ifdef FONT_DEBUG
fprintf(stderr, "resulting in \"%s\".\n", xlfd); fprintf(stderr, "resulting in \"%s\".\n", xlfd);