{
FcConfigParse *parse = userData;
FcChar8 *data;
-
+#ifdef _WIN32
+ FcChar8 buffer[1000];
+#endif
+
if (!parse->pstack)
return;
switch (parse->pstack->element) {
if (strcmp (data, "CUSTOMFONTDIR") == 0)
{
char *p;
- FcStrFree (data);
- data = malloc (1000);
- if (!data)
- {
- FcConfigMessage (parse, FcSevereError, "out of memory");
- break;
- }
- FcMemAlloc (FC_MEM_STRING, 1000);
- if(!GetModuleFileName(NULL, data, 1000))
+ data = buffer;
+ if (!GetModuleFileName (NULL, buffer, sizeof (buffer) - 20))
{
FcConfigMessage (parse, FcSevereError, "GetModuleFileName failed");
- FcStrFree (data);
break;
}
p = strrchr (data, '\\');
else if (strcmp (data, "APPSHAREFONTDIR") == 0)
{
char *p;
- FcStrFree (data);
- data = malloc (1000);
- if (!data)
- {
- FcConfigMessage (parse, FcSevereError, "out of memory");
- break;
- }
- FcMemAlloc (FC_MEM_STRING, 1000);
- if(!GetModuleFileName(NULL, data, 1000))
+ data = buffer;
+ if (!GetModuleFileName (NULL, buffer, sizeof (buffer) - 20))
{
FcConfigMessage (parse, FcSevereError, "GetModuleFileName failed");
- FcStrFree (data);
break;
}
p = strrchr (data, '\\');
else if (strcmp (data, "WINDOWSFONTDIR") == 0)
{
int rc;
- FcStrFree (data);
- data = malloc (1000);
- if (!data)
- {
- FcConfigMessage (parse, FcSevereError, "out of memory");
- break;
- }
- FcMemAlloc (FC_MEM_STRING, 1000);
- rc = GetSystemWindowsDirectory (data, 800);
- if (rc == 0 || rc > 800)
+ data = buffer;
+ rc = GetSystemWindowsDirectory (buffer, sizeof (buffer) - 20);
+ if (rc == 0 || rc > sizeof (buffer) - 20)
{
FcConfigMessage (parse, FcSevereError, "GetSystemWindowsDirectory failed");
- FcStrFree (data);
break;
}
if (data [strlen (data) - 1] != '\\')