git.asbjorn.biz
/
swftools.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
4cf6f83
)
fixed mem leaks
author
Matthias Kramm
<kramm@quiss.org>
Tue, 18 May 2010 01:18:40 +0000
(18:18 -0700)
committer
Matthias Kramm
<kramm@quiss.org>
Tue, 18 May 2010 01:18:40 +0000
(18:18 -0700)
lib/devices/record.c
patch
|
blob
|
history
lib/pdf/BitmapOutputDev.cc
patch
|
blob
|
history
lib/pdf/bbox.c
patch
|
blob
|
history
lib/pdf/pdf.cc
patch
|
blob
|
history
src/pdf2swf.c
patch
|
blob
|
history
diff --git
a/lib/devices/record.c
b/lib/devices/record.c
index
a09cbbc
..
48b57f6
100644
(file)
--- a/
lib/devices/record.c
+++ b/
lib/devices/record.c
@@
-453,6
+453,17
@@
static gfxfont_t*readFont(reader_t*r, state_t*state)
/* ----------------- reading/writing of primitives with caching -------------- */
/* ----------------- reading/writing of primitives with caching -------------- */
+void state_clear(state_t*state)
+{
+ int t;
+ for(t=0;t<sizeof(state->last_string)/sizeof(state->last_string[0]);t++) {
+ if(state->last_string[t]) {
+ free(state->last_string[t]);
+ state->last_string[t] = 0;
+ }
+ }
+}
+
static char* read_string(reader_t*r, state_t*state, U8 id, U8 flags)
{
assert(id>=0 && id<16);
static char* read_string(reader_t*r, state_t*state, U8 id, U8 flags)
{
assert(id>=0 && id<16);
@@
-461,6
+472,9
@@
static char* read_string(reader_t*r, state_t*state, U8 id, U8 flags)
return strdup(state->last_string[id]);
}
char*s = reader_readString(r);
return strdup(state->last_string[id]);
}
char*s = reader_readString(r);
+ if(state->last_string[id]) {
+ free(state->last_string[id]);
+ }
state->last_string[id] = strdup(s);
return s;
}
state->last_string[id] = strdup(s);
return s;
}
@@
-609,7
+623,11
@@
static void record_drawchar(struct _gfxdevice*dev, gfxfont_t*font, int glyphnr,
writer_writeString(&i->w, font_id);
dumpColor(&i->w, &i->state, color);
dumpMatrix(&i->w, &i->state, matrix);
writer_writeString(&i->w, font_id);
dumpColor(&i->w, &i->state, color);
dumpMatrix(&i->w, &i->state, matrix);
+
+ if(i->state.last_string[OP_DRAWCHAR])
+ free(i->state.last_string[OP_DRAWCHAR]);
i->state.last_string[OP_DRAWCHAR] = strdup(font_id);
i->state.last_string[OP_DRAWCHAR] = strdup(font_id);
+
i->state.last_color[OP_DRAWCHAR] = *color;
i->state.last_matrix[OP_DRAWCHAR] = *matrix;
} else {
i->state.last_color[OP_DRAWCHAR] = *color;
i->state.last_matrix[OP_DRAWCHAR] = *matrix;
} else {
@@
-810,6
+828,7
@@
static void replay(struct _gfxdevice*dev, gfxdevice_t*out, reader_t*r, gfxfontli
}
}
finish:
}
}
finish:
+ state_clear(&state);
r->dealloc(r);
if(_fontlist)
gfxfontlist_free(_fontlist, 0);
r->dealloc(r);
if(_fontlist)
gfxfontlist_free(_fontlist, 0);
@@
-927,6
+946,8
@@
static gfxresult_t* record_finish(struct _gfxdevice*dev)
msg("<error> Warning: unclosed cliplevels");
}
msg("<error> Warning: unclosed cliplevels");
}
+ state_clear(&i->state);
+
#ifdef STATS
int total = i->w.pos;
if(total && i->use_tempfile) {
#ifdef STATS
int total = i->w.pos;
if(total && i->use_tempfile) {
diff --git
a/lib/pdf/BitmapOutputDev.cc
b/lib/pdf/BitmapOutputDev.cc
index
5c005d0
..
29cf789
100644
(file)
--- a/
lib/pdf/BitmapOutputDev.cc
+++ b/
lib/pdf/BitmapOutputDev.cc
@@
-81,6
+81,7
@@
BitmapOutputDev::BitmapOutputDev(InfoOutputDev*info, PDFDoc*doc)
this->gfxdev->setDevice(this->gfxoutput);
this->config_extrafontdata = 0;
this->gfxdev->setDevice(this->gfxoutput);
this->config_extrafontdata = 0;
+ this->config_skewedtobitmap = 0;
this->config_optimizeplaincolorfills = 0;
this->bboxpath = 0;
//this->clipdev = 0;
this->config_optimizeplaincolorfills = 0;
this->bboxpath = 0;
//this->clipdev = 0;
diff --git
a/lib/pdf/bbox.c
b/lib/pdf/bbox.c
index
da5f039
..
1f24567
100644
(file)
--- a/
lib/pdf/bbox.c
+++ b/
lib/pdf/bbox.c
@@
-118,6
+118,7
@@
static void head_delete(context_t*context, head_t*h)
assert(!h->prev);
context->heads = h->next;
}
assert(!h->prev);
context->heads = h->next;
}
+ free(h);
}
#define POINTS_TO_HEAD(ptr) (((head_t*)(ptr))->magic==HEAD_MAGIC)
}
#define POINTS_TO_HEAD(ptr) (((head_t*)(ptr))->magic==HEAD_MAGIC)
diff --git
a/lib/pdf/pdf.cc
b/lib/pdf/pdf.cc
index
9324a91
..
f148424
100644
(file)
--- a/
lib/pdf/pdf.cc
+++ b/
lib/pdf/pdf.cc
@@
-186,6
+186,10
@@
void pdf_doc_destroy(gfxdocument_t*gfx)
delete i->doc; i->doc=0;
free(i->pages); i->pages = 0;
delete i->doc; i->doc=0;
free(i->pages); i->pages = 0;
+
+ if(i->pagemap) {
+ free(i->pagemap);
+ }
i->docinfo.free();
i->docinfo.free();
@@
-196,6
+200,10
@@
void pdf_doc_destroy(gfxdocument_t*gfx)
if(i->info) {
delete i->info;i->info=0;
}
if(i->info) {
delete i->info;i->info=0;
}
+ if(i->parameters) {
+ gfxparams_free(i->parameters);
+ i->parameters=0;
+ }
free(gfx->internal);gfx->internal=0;
free(gfx);gfx=0;
free(gfx->internal);gfx->internal=0;
free(gfx);gfx=0;
diff --git
a/src/pdf2swf.c
b/src/pdf2swf.c
index
e333eb3
..
3b67bcc
100644
(file)
--- a/
src/pdf2swf.c
+++ b/
src/pdf2swf.c
@@
-260,7
+260,7
@@
int args_callback_option(char*name,char*val) {
}
else if (!strcmp(name, "s"))
{
}
else if (!strcmp(name, "s"))
{
- char*s = strdup(val);
+ char*s = val;
char*c = strchr(s, '=');
if(c && *c && c[1]) {
*c = 0;
char*c = strchr(s, '=');
if(c && *c && c[1]) {
*c = 0;