Ensure we don't leak random memory into our IFF DR2D files

This commit is contained in:
Chris Young 2016-05-02 15:24:17 +01:00
parent 990598ccdc
commit 54441c7c58
1 changed files with 7 additions and 5 deletions

View File

@ -28,10 +28,12 @@
#ifndef AMIGA_DR2D_STANDALONE #ifndef AMIGA_DR2D_STANDALONE
#include "amiga/os3support.h" #include "amiga/os3support.h"
#include "amiga/iff_dr2d.h" #include "amiga/iff_dr2d.h"
#include "amiga/misc.h"
#include "content/hlcache.h" #include "content/hlcache.h"
#else #else
#include "os3support.h" #include "os3support.h"
#include "iff_dr2d.h" #include "iff_dr2d.h"
#include "misc.h"
#endif #endif
struct ColorRegister cm[1000]; struct ColorRegister cm[1000];
@ -123,9 +125,9 @@ bool ami_svg_to_dr2d(struct IFFHandle *iffh, const char *buffer,
PopChunk(iffh); PopChunk(iffh);
} }
if(!(PushChunk(iffh,0,ID_ANNO,18))) if(!(PushChunk(iffh,0,ID_ANNO,19)))
{ {
WriteChunkBytes(iffh,"Created by NetSurf",18); WriteChunkBytes(iffh,"Created by NetSurf\0",19);
PopChunk(iffh); PopChunk(iffh);
} }
@ -170,7 +172,7 @@ bool ami_svg_to_dr2d(struct IFFHandle *iffh, const char *buffer,
} }
for (i = 0; i != diagram->shape_count; i++) { for (i = 0; i != diagram->shape_count; i++) {
attr = AllocVecTagList(sizeof(struct attr_struct), NULL); attr = ami_misc_allocvec_clear(sizeof(struct attr_struct), 0);
if (diagram->shape[i].fill == svgtiny_TRANSPARENT) if (diagram->shape[i].fill == svgtiny_TRANSPARENT)
attr->FillType = FT_NONE; attr->FillType = FT_NONE;
else else
@ -271,13 +273,13 @@ bool ami_svg_to_dr2d(struct IFFHandle *iffh, const char *buffer,
PopChunk(iffh); PopChunk(iffh);
} }
} else if (diagram->shape[i].text) { } else if (diagram->shape[i].text) {
stxt = AllocVecTagList(sizeof(struct stxt_struct), NULL); stxt = ami_misc_allocvec_clear(sizeof(struct stxt_struct), 0);
stxt->BaseX = diagram->shape[i].text_x; stxt->BaseX = diagram->shape[i].text_x;
stxt->BaseY = diagram->shape[i].text_y; stxt->BaseY = diagram->shape[i].text_y;
stxt->NumChars = strlen(diagram->shape[i].text); stxt->NumChars = strlen(diagram->shape[i].text);
if(!fons_written) if(!fons_written)
{ {
fons = AllocVecTagList(sizeof(struct fons_struct), NULL); fons = ami_misc_allocvec_clear(sizeof(struct fons_struct), 0);
if(!(PushChunk(iffh,0,ID_FONS,IFFSIZE_UNKNOWN))) if(!(PushChunk(iffh,0,ID_FONS,IFFSIZE_UNKNOWN)))
{ {
WriteChunkBytes(iffh, fons, sizeof(struct fons_struct)); WriteChunkBytes(iffh, fons, sizeof(struct fons_struct));