aboutsummaryrefslogtreecommitdiff
path: root/mkfontscale
diff options
context:
space:
mode:
Diffstat (limited to 'mkfontscale')
-rw-r--r--mkfontscale/list.c7
-rw-r--r--mkfontscale/mkfontscale.c24
2 files changed, 22 insertions, 9 deletions
diff --git a/mkfontscale/list.c b/mkfontscale/list.c
index 1614d9537..320ce20c6 100644
--- a/mkfontscale/list.c
+++ b/mkfontscale/list.c
@@ -235,7 +235,12 @@ sortList(ListPtr old)
int i;
int l = listLength(old);
ListPtr n;
- ListPtr *sorted = malloc(l * sizeof(ListPtr));
+ ListPtr *sorted;
+
+ if (l <= 0)
+ return old;
+
+ sorted = malloc(l * sizeof(ListPtr));
if (sorted == NULL)
return old;
diff --git a/mkfontscale/mkfontscale.c b/mkfontscale/mkfontscale.c
index b01d80a27..a2e96fff0 100644
--- a/mkfontscale/mkfontscale.c
+++ b/mkfontscale/mkfontscale.c
@@ -494,7 +494,7 @@ safe(const char* s)
i++;
}
- if(safe_flag) return s;
+ if(safe_flag) return strdup(s);
len = i;
t = malloc(len + 1);
@@ -518,7 +518,7 @@ makeXLFD(char *filename, FT_Face face, int isBitmap)
{
ListPtr xlfd = NULL;
const char *foundry, *family, *weight, *slant, *sWidth, *adstyle,
- *spacing, *full_name;
+ *spacing, *full_name, *tmp;
TT_Header *head;
TT_HoriHeader *hhea;
TT_OS2 *os2;
@@ -586,11 +586,11 @@ makeXLFD(char *filename, FT_Face face, int isBitmap)
if(t1info) {
if(!family)
- family = t1info->family_name;
+ family = strdup(t1info->family_name);
if(!family)
- family = t1info->full_name;
+ family = strdup(t1info->full_name);
if(!full_name)
- full_name = t1info->full_name;
+ full_name = strdup(t1info->full_name);
if(!foundry)
foundry = notice_foundry(t1info->notice);
if(!weight)
@@ -607,7 +607,7 @@ makeXLFD(char *filename, FT_Face face, int isBitmap)
if(!full_name) {
fprintf(stderr, "Couldn't determine full name for %s\n", filename);
- full_name = filename;
+ full_name = strdup(filename);
}
if(head) {
@@ -632,11 +632,13 @@ makeXLFD(char *filename, FT_Face face, int isBitmap)
notice = getName(face, TT_NAME_ID_TRADEMARK);
if(notice) {
foundry = notice_foundry(notice);
+ free(notice);
}
if(!foundry) {
notice = getName(face, TT_NAME_ID_MANUFACTURER);
if(notice) {
foundry = notice_foundry(notice);
+ free(notice);
}
}
}
@@ -654,7 +656,7 @@ makeXLFD(char *filename, FT_Face face, int isBitmap)
if(!foundry) foundry = "misc";
if(!family) {
fprintf(stderr, "Couldn't get family name for %s\n", filename);
- family = filename;
+ family = strdup(filename);
}
if(!weight) weight = "medium";
@@ -663,9 +665,11 @@ makeXLFD(char *filename, FT_Face face, int isBitmap)
if(!adstyle) adstyle = "";
if(!spacing) spacing = "p";
- /* Yes, it's a memory leak. */
foundry = safe(foundry);
+
+ tmp = family;
family = safe(family);
+ free((void *)tmp);
if(!isBitmap) {
xlfd = listConsF(xlfd,
@@ -688,6 +692,10 @@ makeXLFD(char *filename, FT_Face face, int isBitmap)
spacing, 60);
}
}
+
+ free((void *)family);
+ free((void *)foundry);
+ free((void *)full_name);
return xlfd;
}