From d3d4e266e71678c12d46710c52c720c3c5c58b98 Mon Sep 17 00:00:00 2001 From: Tim Waugh Date: Aug 10 2011 15:48:11 +0000 Subject: Coverity fix (resource-leak). --- diff --git a/a2ps-resource-leak.patch b/a2ps-resource-leak.patch new file mode 100644 index 0000000..d84d0cd --- /dev/null +++ b/a2ps-resource-leak.patch @@ -0,0 +1,49 @@ +diff -up a2ps-4.14/lib/encoding.c.resource-leak a2ps-4.14/lib/encoding.c +--- a2ps-4.14/lib/encoding.c.resource-leak 2011-08-10 16:02:26.244905923 +0100 ++++ a2ps-4.14/lib/encoding.c 2011-08-10 16:41:39.578353192 +0100 +@@ -554,7 +554,7 @@ encoding_resolve_font_substitute (struct + if (!res) + { + if (encoding->default_font) +- res = encoding->default_font; ++ res = xstrdup (encoding->default_font); + else + error (1, 0, "Cannot find font %s, nor any substitute", + font_name); +@@ -976,6 +976,7 @@ dump_encoding_setup (FILE * stream, + font_names [i]); + if (!font_is_to_reencode (job, real_font_name)) + da_remove_at (encoding->font_names_used, i, (da_map_func_t) free); ++ free (real_font_name); + } + + /* The number of fonts that, finally, have to be encoded +@@ -992,10 +993,16 @@ dump_encoding_setup (FILE * stream, + fprintf (stream, "/%sdict %d dict begin\n", encoding->key, + (encoding->composite_flag == true)? nb+nb+ns:nb+ns); + for (i = 0 ; i < nb ; i++) +- fprintf (stream, " /f%s %sEncoding /%s reencode_font\n", +- font_names [i], +- encoding->name, +- encoding_resolve_font_substitute (job, encoding, font_names [i])); ++ { ++ char *real_font = encoding_resolve_font_substitute (job, encoding, ++ font_names [i]); ++ fprintf (stream, " /f%s %sEncoding /%s reencode_font\n", ++ font_names [i], ++ encoding->name, ++ real_font); ++ free (real_font); ++ } ++ + + /* Slant font setting */ + for (i = 0 ; encoding->slantfont[i].name ; i++ ) +@@ -1166,6 +1173,7 @@ encoding_build_faces_wx (a2ps_job * job, + encoding->vector, + encoding->faces_wx [face]); + ++ free (true_font_name); + if (encoding->composite_flag) + { + encoding->composite_raito[i] = diff --git a/a2ps.spec b/a2ps.spec index 2b0896b..947a345 100644 --- a/a2ps.spec +++ b/a2ps.spec @@ -32,6 +32,7 @@ Patch35: a2ps-4.14-texinfo-nodes.patch Patch36: a2ps-forward-null.patch Patch37: a2ps-overrun-dynamic.patch Patch38: a2ps-overrun-static.patch +Patch39: a2ps-resource-leak.patch Requires: fileutils sh-utils info BuildRequires: gperf BuildRequires: emacs, flex, libtool, texinfo, groff @@ -151,6 +152,9 @@ the emacs-%{name} package to use emacs-%{name} with GNU Emacs. # Coverity fix (overrun-static). %patch38 -p1 -b .overrun-static +# Coverity fix (resource-leak). +%patch39 -p1 -b .resource-leak + for file in AUTHORS ChangeLog; do iconv -f latin1 -t UTF-8 < $file > $file.utf8 touch -c -r $file $file.utf8 @@ -291,6 +295,7 @@ exit 0 %changelog * Wed Aug 10 2011 Tim Waugh - 4.14-13 +- Coverity fix (resource-leak). - Coverity fix (overrun-static). - Coverity fix (overrun-dynamic). - Coverity fix (forward-null).