diff options
author | horwitz <horwitz@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2009-06-16 21:41:39 +0000 |
---|---|---|
committer | horwitz <horwitz@ffa7fe5e-494d-0410-b361-a75ebd5db220> | 2009-06-16 21:41:39 +0000 |
commit | db2dbcfeaf6f04299312804ca3d0612792ec07b4 (patch) | |
tree | bd1f8d92d9bade71106f5d6275aaab9bc88e37eb /navit/font | |
parent | 6931b4092bb070daee95598f8fde231f3b35965b (diff) | |
download | navit-db2dbcfeaf6f04299312804ca3d0612792ec07b4.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.c | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/navit/font/freetype/font_freetype.c b/navit/font/freetype/font_freetype.c index 023c9fdfe..313d27987 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 |