* src/sfnt/sfdriver.c (get_sfnt_postscript_name): fixed memory leak
This commit is contained in:
parent
2bf2b9cc21
commit
678e0d46cd
|
@ -115,6 +115,7 @@
|
||||||
get_sfnt_postscript_name( TT_Face face )
|
get_sfnt_postscript_name( TT_Face face )
|
||||||
{
|
{
|
||||||
FT_Int n, found_win, found_apple;
|
FT_Int n, found_win, found_apple;
|
||||||
|
const char* result = NULL;
|
||||||
|
|
||||||
|
|
||||||
/* shouldn't happen, but just in case to avoid memory leaks */
|
/* shouldn't happen, but just in case to avoid memory leaks */
|
||||||
|
@ -151,11 +152,10 @@
|
||||||
TT_NameEntryRec* name = face->name_table.names + found_win;
|
TT_NameEntryRec* name = face->name_table.names + found_win;
|
||||||
FT_UInt len = name->stringLength/2;
|
FT_UInt len = name->stringLength/2;
|
||||||
FT_Error error;
|
FT_Error error;
|
||||||
FT_String* result;
|
|
||||||
|
|
||||||
if ( !ALLOC( result, len+1 ) )
|
if ( !ALLOC( result, len+1 ) )
|
||||||
{
|
{
|
||||||
FT_String* r = result;
|
FT_String* r = (FT_String*)result;
|
||||||
FT_Byte* p = (FT_Byte*) name->string;
|
FT_Byte* p = (FT_Byte*) name->string;
|
||||||
|
|
||||||
for ( ; len > 0; len--, p += 2 )
|
for ( ; len > 0; len--, p += 2 )
|
||||||
|
@ -165,7 +165,7 @@
|
||||||
}
|
}
|
||||||
*r = '\0';
|
*r = '\0';
|
||||||
}
|
}
|
||||||
return result;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( found_apple )
|
if ( found_apple )
|
||||||
|
@ -181,10 +181,12 @@
|
||||||
MEM_Copy( result, name->string, len );
|
MEM_Copy( result, name->string, len );
|
||||||
result[len] = '\0';
|
result[len] = '\0';
|
||||||
}
|
}
|
||||||
return result;
|
goto Exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
Exit:
|
||||||
|
face->root.internal->postscript_name = result;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue