提交 4f96f754 编写于 作者: I igor

6887292: memory leak in freetypeScaler.c

Reviewed-by: bae, prr
上级 6abfb816
......@@ -102,9 +102,21 @@ Java_sun_font_FreetypeFontScaler_initIDs(
}
static void freeNativeResources(JNIEnv *env, FTScalerInfo* scalerInfo) {
void *stream;
if (scalerInfo == NULL)
return;
//apparently Done_Face will only close the stream
// but will not relase the memory of stream structure.
// We need to free it explicitly to avoid leak.
//Direct access to the stream field might be not ideal solution as
// it is considred to be "private".
//Alternatively we could have stored pointer to the structure
// in the scalerInfo but this will increase size of the structure
// for no good reason
stream = scalerInfo->face->stream;
FT_Done_Face(scalerInfo->face);
FT_Done_FreeType(scalerInfo->library);
......@@ -116,6 +128,10 @@ static void freeNativeResources(JNIEnv *env, FTScalerInfo* scalerInfo) {
free(scalerInfo->fontData);
}
if (stream != NULL) {
free(stream);
}
free(scalerInfo);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册