summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2009-03-16 17:57:01 +0100
committerTor Andersson <tor@ghostscript.com>2009-03-16 17:57:01 +0100
commit980a0d258749fa975d8dd2b44071996ee21e3bb6 (patch)
treeee32872e548d4b0a266eb5e25d0b2fb6ac01d016
parent3084208daf0c5b5ea8c8763adcf2107b5817d863 (diff)
downloadmupdf-980a0d258749fa975d8dd2b44071996ee21e3bb6.tar.xz
Fix some Coverity issues.
-rw-r--r--apps/pdfinfo.c6
-rw-r--r--apps/unix/x11pdf.c1
-rw-r--r--fitz/filt_faxd.c2
-rw-r--r--fitz/filt_faxe.c2
-rw-r--r--fitz/fitz_base.h3
-rw-r--r--fitz/fitz_draw.h10
-rw-r--r--fitz/fitz_tree.h10
-rw-r--r--fitz/res_font.c2
-rw-r--r--mupdf/cmapdump.c6
-rw-r--r--mupdf/mupdf.h1
-rw-r--r--mupdf/pdf_build.c3
-rw-r--r--mupdf/pdf_cmap.c3
-rw-r--r--mupdf/pdf_cmap_load.c4
-rw-r--r--mupdf/pdf_font.c23
-rw-r--r--mupdf/pdf_fontfile.c4
-rw-r--r--mupdf/pdf_function.c2
16 files changed, 47 insertions, 35 deletions
diff --git a/apps/pdfinfo.c b/apps/pdfinfo.c
index 1680f1b1..8763ac5c 100644
--- a/apps/pdfinfo.c
+++ b/apps/pdfinfo.c
@@ -6,12 +6,6 @@
#include "fitz.h"
#include "mupdf.h"
-#ifdef _MSC_VER
-#include <winsock2.h>
-#else
-#include <sys/time.h>
-#endif
-
/* put these up here so we can clean up in die() */
fz_renderer *drawgc = nil;
void closesrc(void);
diff --git a/apps/unix/x11pdf.c b/apps/unix/x11pdf.c
index 42fd6a98..f2290388 100644
--- a/apps/unix/x11pdf.c
+++ b/apps/unix/x11pdf.c
@@ -8,7 +8,6 @@
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/cursorfont.h>
-#include <X11/keysym.h>
#include <sys/select.h>
#include <sys/time.h>
diff --git a/fitz/filt_faxd.c b/fitz/filt_faxd.c
index cc083138..2a371d4f 100644
--- a/fitz/filt_faxd.c
+++ b/fitz/filt_faxd.c
@@ -101,8 +101,8 @@ fz_newfaxd(fz_filter **fp, fz_obj *params)
fax->dst = fz_malloc(fax->stride);
if (!fax->dst)
{
- fz_free(fax);
fz_free(fax->ref);
+ fz_free(fax);
return fz_rethrow(-1, "out of memory: scanline buffer two");
}
diff --git a/fitz/filt_faxe.c b/fitz/filt_faxe.c
index db152ae5..9511da88 100644
--- a/fitz/filt_faxe.c
+++ b/fitz/filt_faxe.c
@@ -84,8 +84,8 @@ fz_newfaxe(fz_filter **fp, fz_obj *params)
fax->src = fz_malloc(fax->stride);
if (!fax->src)
{
- fz_free(fax);
fz_free(fax->ref);
+ fz_free(fax);
return fz_rethrow(-1, "out of memoryory: scanline buffer two");
}
diff --git a/fitz/fitz_base.h b/fitz/fitz_base.h
index 6bee3ecb..23198665 100644
--- a/fitz/fitz_base.h
+++ b/fitz/fitz_base.h
@@ -37,11 +37,14 @@ extern int fz_strlcpy(char *dst, const char *src, int n);
extern int fz_strlcat(char *dst, const char *src, int n);
#ifdef NEED_STRSEP
+#undef strsep
#define strsep fz_strsep
#endif
#ifdef NEED_STRLCPY
+#undef strlcpy
#define strlcpy fz_strlcpy
+#undef strlcat
#define strlcat fz_strlcat
#endif
diff --git a/fitz/fitz_draw.h b/fitz/fitz_draw.h
index 494374da..f07d31ab 100644
--- a/fitz/fitz_draw.h
+++ b/fitz/fitz_draw.h
@@ -9,6 +9,16 @@ typedef struct fz_renderer_s fz_renderer;
#define FZ_PCTM \
int u0, int v0, int fa, int fb, int fc, int fd, int w0, int h
+typedef struct fz_glyph_s fz_glyph;
+typedef struct fz_glyphcache_s fz_glyphcache;
+
+fz_error fz_renderftglyph(fz_glyph *glyph, fz_font *font, int cid, fz_matrix trm);
+fz_error fz_rendert3glyph(fz_glyph *glyph, fz_font *font, int cid, fz_matrix trm);
+fz_error fz_newglyphcache(fz_glyphcache **arenap, int slots, int size);
+fz_error fz_renderglyph(fz_glyphcache*, fz_glyph*, fz_font*, int, fz_matrix);
+void fz_debugglyphcache(fz_glyphcache *);
+void fz_dropglyphcache(fz_glyphcache *);
+
typedef struct fz_edge_s fz_edge;
typedef struct fz_gel_s fz_gel;
typedef struct fz_ael_s fz_ael;
diff --git a/fitz/fitz_tree.h b/fitz/fitz_tree.h
index 205441ad..0c29c359 100644
--- a/fitz/fitz_tree.h
+++ b/fitz/fitz_tree.h
@@ -344,9 +344,6 @@ void fz_convertpixmap(fz_colorspace *srcs, fz_pixmap *srcv, fz_colorspace *dsts,
void fz_stdconvcolor(fz_colorspace *srcs, float *srcv, fz_colorspace *dsts, float *dstv);
void fz_stdconvpixmap(fz_colorspace *srcs, fz_pixmap *srcv, fz_colorspace *dsts, fz_pixmap *dstv);
-typedef struct fz_glyph_s fz_glyph;
-typedef struct fz_glyphcache_s fz_glyphcache;
-
char *ft_errorstring(int err);
struct fz_font_s
@@ -385,13 +382,6 @@ void fz_dropfont(fz_font *font);
void fz_debugfont(fz_font *font);
void fz_setfontbbox(fz_font *font, int xmin, int ymin, int xmax, int ymax);
-fz_error fz_renderftglyph(fz_glyph *glyph, fz_font *font, int cid, fz_matrix trm);
-fz_error fz_rendert3glyph(fz_glyph *glyph, fz_font *font, int cid, fz_matrix trm);
-fz_error fz_newglyphcache(fz_glyphcache **arenap, int slots, int size);
-fz_error fz_renderglyph(fz_glyphcache*, fz_glyph*, fz_font*, int, fz_matrix);
-void fz_debugglyphcache(fz_glyphcache *);
-void fz_dropglyphcache(fz_glyphcache *);
-
/* loadtile will fill a pixmap with the pixel samples. non-premultiplied alpha. */
struct fz_image_s
diff --git a/fitz/res_font.c b/fitz/res_font.c
index 00bb10d4..884de8ff 100644
--- a/fitz/res_font.c
+++ b/fitz/res_font.c
@@ -1,6 +1,6 @@
#include "fitz_base.h"
#include "fitz_tree.h"
-#include "fitz_draw.h" /* for type3 font rendering */
+#include "fitz_draw.h" /* FIXME -- for glyph rendering callbacks */
#include <ft2build.h>
#include FT_FREETYPE_H
diff --git a/mupdf/cmapdump.c b/mupdf/cmapdump.c
index 596e3e51..0c322a78 100644
--- a/mupdf/cmapdump.c
+++ b/mupdf/cmapdump.c
@@ -73,6 +73,12 @@ main(int argc, char **argv)
else
realname = argv[i];
+ if (strlen(realname) > (sizeof name - 1))
+ {
+ fprintf(stderr, "cmapdump: file name too long\n");
+ return 1;
+ }
+
strcpy(name, realname);
p = name;
while (*p)
diff --git a/mupdf/mupdf.h b/mupdf/mupdf.h
index 95d5d648..64dc893b 100644
--- a/mupdf/mupdf.h
+++ b/mupdf/mupdf.h
@@ -414,6 +414,7 @@ struct pdf_fontdesc_s
int refs;
fz_font *font;
+ char *buffer; /* contains allocated memory that should be freed */
/* FontDescriptor */
int flags;
diff --git a/mupdf/pdf_build.c b/mupdf/pdf_build.c
index 26ed9b9d..77f01184 100644
--- a/mupdf/pdf_build.c
+++ b/mupdf/pdf_build.c
@@ -922,7 +922,8 @@ showglyph(pdf_csi *csi, int cid)
tx = (w0 * gstate->size + gstate->charspace) * gstate->scale;
csi->tm = fz_concat(fz_translate(tx, 0), csi->tm);
}
- else
+
+ if (fontdesc->wmode == 1)
{
w1 = v.w / 1000.0;
ty = w1 * gstate->size + gstate->charspace;
diff --git a/mupdf/pdf_cmap.c b/mupdf/pdf_cmap.c
index 241d8591..7ea130d8 100644
--- a/mupdf/pdf_cmap.c
+++ b/mupdf/pdf_cmap.c
@@ -427,8 +427,7 @@ pdf_sortcmap(pdf_cmap *cmap)
if (!newranges)
return fz_rethrow(-1, "out of memory: cmap ranges");
cmap->rcap = cmap->rlen;
- if (cmap->refs >= 0)
- cmap->ranges = newranges;
+ cmap->ranges = newranges;
if (cmap->tlen)
{
diff --git a/mupdf/pdf_cmap_load.c b/mupdf/pdf_cmap_load.c
index f1553e33..d8c3d8ec 100644
--- a/mupdf/pdf_cmap_load.c
+++ b/mupdf/pdf_cmap_load.c
@@ -9,7 +9,7 @@ pdf_loadembeddedcmap(pdf_cmap **cmapp, pdf_xref *xref, fz_obj *stmref)
{
fz_error error = fz_okay;
fz_obj *stmobj = stmref;
- fz_stream *file;
+ fz_stream *file = nil;
pdf_cmap *cmap = nil;
pdf_cmap *usecmap;
fz_obj *wmode;
@@ -91,6 +91,8 @@ pdf_loadembeddedcmap(pdf_cmap **cmapp, pdf_xref *xref, fz_obj *stmref)
return fz_okay;
cleanup:
+ if (file)
+ fz_dropstream(file);
if (cmap)
pdf_dropcmap(cmap);
fz_dropobj(stmobj);
diff --git a/mupdf/pdf_font.c b/mupdf/pdf_font.c
index 649dc591..fc912435 100644
--- a/mupdf/pdf_font.c
+++ b/mupdf/pdf_font.c
@@ -139,6 +139,8 @@ pdf_dropfont(pdf_fontdesc *fontdesc)
{
if (fontdesc->font)
fz_dropfont(fontdesc->font);
+ if (fontdesc->buffer)
+ fz_free(fontdesc->buffer);
if (fontdesc->encoding)
pdf_dropcmap(fontdesc->encoding);
if (fontdesc->tottfcmap)
@@ -165,6 +167,7 @@ pdf_newfontdesc(void)
fontdesc->refs = 1;
fontdesc->font = nil;
+ fontdesc->buffer = nil;
fontdesc->flags = 0;
fontdesc->italicangle = 0;
@@ -664,13 +667,14 @@ loadcidfont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict, fz_obj *ref,
/* unicode cmap to get a glyph id */
else if (fontdesc->font->ftsubstitute)
{
- int e;
-
pdf_logfont("emulate ttf cidfont\n");
- e = FT_Select_Charmap(face, ft_encoding_unicode);
- if (e)
- return fz_throw("fonterror: no unicode cmap when emulating CID font");
+ error = FT_Select_Charmap(face, ft_encoding_unicode);
+ if (error)
+ {
+ error = fz_throw("fonterror: no unicode cmap when emulating CID font");
+ goto cleanup;
+ }
if (!strcmp(collection, "Adobe-CNS1"))
error = pdf_loadsystemcmap(&fontdesc->tottfcmap, "Adobe-CNS1-UCS2");
@@ -686,7 +690,10 @@ loadcidfont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict, fz_obj *ref,
error = fz_okay;
if (error)
- return fz_rethrow(error, "cannot load system cmap %s", collection);
+ {
+ error = fz_rethrow(error, "cannot load system cmap %s", collection);
+ goto cleanup;
+ }
}
}
@@ -695,7 +702,7 @@ loadcidfont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict, fz_obj *ref,
goto cleanup;
/* Rudimentary check for DynaLab fonts */
- if (kind == TRUETYPE && collection && strstr(collection, "Adobe-"))
+ if (kind == TRUETYPE && strstr(collection, "Adobe-"))
fontdesc->font->fthint = 1;
/*
@@ -972,7 +979,7 @@ pdf_loadfont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict, fz_obj *ref
error = pdf_storeitem(xref->store, PDF_KFONT, ref, *fontdescp);
if (error)
- return fz_rethrow(error, "cannot store font resource");
+ return fz_rethrow(error, "cannot store font resource");
return fz_okay;
}
diff --git a/mupdf/pdf_fontfile.c b/mupdf/pdf_fontfile.c
index 0d6889d4..d3ee0a63 100644
--- a/mupdf/pdf_fontfile.c
+++ b/mupdf/pdf_fontfile.c
@@ -279,8 +279,8 @@ pdf_loadembeddedfont(pdf_fontdesc *font, pdf_xref *xref, fz_obj *stmref)
return fz_rethrow(error, "cannot load embedded font (%d %d R)", fz_tonum(stmref), fz_togen(stmref));
}
-//XXX font->ftbuffer = buf->rp; /* save the buffer so we can free it later */
-// fz_free(buf); /* only free the fz_buffer struct, not the contained data */
+ font->buffer = buf->rp; /* save the buffer so we can free it later */
+ fz_free(buf); /* only free the fz_buffer struct, not the contained data */
return fz_okay;
}
diff --git a/mupdf/pdf_function.c b/mupdf/pdf_function.c
index 5ec84275..42c6cd49 100644
--- a/mupdf/pdf_function.c
+++ b/mupdf/pdf_function.c
@@ -1552,7 +1552,7 @@ pdf_loadfunction(pdf_function **funcp, pdf_xref *xref, fz_obj *ref)
default:
fz_free(func);
fz_dropobj(dict);
- return fz_throw("unknown function type %d (%d %d R)", func->type, fz_tonum(ref), fz_togen(ref));
+ return fz_throw("unknown function type (%d %d R)", fz_tonum(ref), fz_togen(ref));
}
fz_dropobj(dict);