summaryrefslogtreecommitdiff
path: root/navit/font
diff options
context:
space:
mode:
authorhorwitz <horwitz@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-06-16 21:41:39 +0000
committerhorwitz <horwitz@ffa7fe5e-494d-0410-b361-a75ebd5db220>2009-06-16 21:41:39 +0000
commit37b78408f2ee7a635f6ac1bfc8a06bc92f7d7e8b (patch)
treebd1f8d92d9bade71106f5d6275aaab9bc88e37eb /navit/font
parent3444f3c64bfbca629817a4f9d2d236c0319cb0b3 (diff)
downloadnavit-svn-37b78408f2ee7a635f6ac1bfc8a06bc92f7d7e8b.tar.gz
Fix:Core:Fix coverity bug #20 and #21, Value 'family' not freed or pointed-to.
git-svn-id: http://svn.code.sf.net/p/navit/code/trunk/navit@2334 ffa7fe5e-494d-0410-b361-a75ebd5db220
Diffstat (limited to 'navit/font')
-rw-r--r--navit/font/freetype/font_freetype.c28
1 files changed, 11 insertions, 17 deletions
diff --git a/navit/font/freetype/font_freetype.c b/navit/font/freetype/font_freetype.c
index 023c9fdf..313d2798 100644
--- a/navit/font/freetype/font_freetype.c
+++ b/navit/font/freetype/font_freetype.c
@@ -336,7 +336,7 @@ font_freetype_font_new(struct graphics_priv *gr,
*meth = font_methods;
int exact, found=0;
- char **family;
+ char **family, **family_sav;
#if USE_CACHING
char *idstr;
FT_Face face;
@@ -358,23 +358,16 @@ font_freetype_font_new(struct graphics_priv *gr,
font->size=size;
#ifdef HAVE_FONTCONFIG
dbg(2, " about to search for fonts, prefered = %s\n", fontfamily);
+ family = g_malloc(sizeof(fontfamilies) + sizeof(fontfamily));
+ if (fontfamily) {
+ memcpy(family, &fontfamily, sizeof(fontfamily));
+ memcpy(family + 1, fontfamilies, sizeof(fontfamilies));
+ } else {
+ memcpy(family, fontfamilies, sizeof(fontfamilies));
+ }
+ family_sav=family;
for (exact = 1; !found && exact >= 0; exact--) {
- if (fontfamily) {
- /* prepend the font passed so we look for it first */
- family =
- malloc(sizeof(fontfamilies) +
- sizeof(fontfamily));
- if (!family) {
- dbg(0,
- "Out of memory while creating the font families table\n");
- return NULL;
- }
- memcpy(family, &fontfamily, sizeof(fontfamily));
- memcpy(family + 1, fontfamilies,
- sizeof(fontfamilies));
- } else {
- family = fontfamilies;
- }
+ family=family_sav;
while (*family && !found) {
@@ -442,6 +435,7 @@ font_freetype_font_new(struct graphics_priv *gr,
family++;
}
}
+ g_free(family_sav);
#else
name=g_strdup_printf("%s/fonts/%s-%s.ttf",getenv("NAVIT_SHAREDIR"),"LiberationSans",flags ? "Bold":"Regular");
#if USE_CACHING