libmemdraw: fix CID 154389 (uninitialized variable)

This commit is contained in:
Giacomo Tesio 2017-08-14 13:00:30 +02:00
parent 93c784fa3f
commit 8464d1a277
1 changed files with 38 additions and 37 deletions

View File

@ -378,20 +378,20 @@ static uint8_t ones = 0xff;
typedef struct Buffer Buffer; typedef struct Buffer Buffer;
struct Buffer { struct Buffer {
/* used by most routines */ /* used by most routines */
uint8_t *red; uint8_t* red;
uint8_t *grn; uint8_t* grn;
uint8_t *blu; uint8_t* blu;
uint8_t *alpha; uint8_t* alpha;
uint8_t *grey; uint8_t* grey;
uint32_t *rgba; uint32_t* rgba;
int delta; /* number of bytes to add to pointer to get next pixel to the right */ int delta; /* number of bytes to add to pointer to get next pixel to the right */
/* used by boolcalc* for mask data */ /* used by boolcalc* for mask data */
uint8_t *m; /* ptr to mask data r.min byte; like p->bytermin */ uint8_t* m; /* ptr to mask data r.min byte; like p->bytermin */
int mskip; /* no. of left bits to skip in *m */ int mskip; /* no. of left bits to skip in *m */
uint8_t *bm; /* ptr to mask data img->r.min byte; like p->bytey0s */ uint8_t* bm; /* ptr to mask data img->r.min byte; like p->bytey0s */
int bmskip; /* no. of left bits to skip in *bm */ int bmskip; /* no. of left bits to skip in *bm */
uint8_t *em; /* ptr to mask data img->r.max.x byte; like p->bytey0e */ uint8_t* em; /* ptr to mask data img->r.max.x byte; like p->bytey0e */
int emskip; /* no. of right bits to skip in *em */ int emskip; /* no. of right bits to skip in *em */
}; };
@ -406,36 +406,36 @@ enum {
/* giant rathole to customize functions with */ /* giant rathole to customize functions with */
struct Param { struct Param {
Readfn *replcall; Readfn* replcall;
Readfn *greymaskcall; Readfn* greymaskcall;
Readfn *convreadcall; Readfn* convreadcall;
Writefn *convwritecall; Writefn* convwritecall;
Memimage *img; Memimage* img;
Rectangle r; Rectangle r;
int dx; /* of r */ int dx; /* of r */
int needbuf; int needbuf;
int convgrey; int convgrey;
int alphaonly; int alphaonly;
uint8_t *bytey0s; /* byteaddr(Pt(img->r.min.x, img->r.min.y)) */ uint8_t* bytey0s; /* byteaddr(Pt(img->r.min.x, img->r.min.y)) */
uint8_t *bytermin; /* byteaddr(Pt(r.min.x, img->r.min.y)) */ uint8_t* bytermin; /* byteaddr(Pt(r.min.x, img->r.min.y)) */
uint8_t *bytey0e; /* byteaddr(Pt(img->r.max.x, img->r.min.y)) */ uint8_t* bytey0e; /* byteaddr(Pt(img->r.max.x, img->r.min.y)) */
int bwidth; int bwidth;
int replcache; /* if set, cache buffers */ int replcache; /* if set, cache buffers */
Buffer bcache[MAXBCACHE]; Buffer bcache[MAXBCACHE];
uint32_t bfilled; uint32_t bfilled;
uint8_t *bufbase; uint8_t* bufbase;
int bufoff; int bufoff;
int bufdelta; int bufdelta;
int dir; int dir;
int convbufoff; int convbufoff;
uint8_t *convbuf; uint8_t* convbuf;
Param *convdpar; Param* convdpar;
int convdx; int convdx;
}; };
static Readfn greymaskread, replread, readptr; static Readfn greymaskread, replread, readptr;
@ -450,7 +450,7 @@ static Writefn* writefn(Memimage*);
static Calcfn* boolcopyfn(Memimage*, Memimage*); static Calcfn* boolcopyfn(Memimage*, Memimage*);
static Readfn* convfn(Memimage*, Param*, Memimage*, Param*, int*); static Readfn* convfn(Memimage*, Param*, Memimage*, Param*, int*);
static Calcfn *alphacalc[Ncomp] = static Calcfn* alphacalc[Ncomp] =
{ {
alphacalc0, /* Clear */ alphacalc0, /* Clear */
alphacalc14, /* DoutS */ alphacalc14, /* DoutS */
@ -488,10 +488,10 @@ static Calcfn *boolcalc[Ncomp] =
typedef struct Dbuf Dbuf; typedef struct Dbuf Dbuf;
struct Dbuf struct Dbuf
{ {
uint8_t *p; uint8_t* p;
int n; int n;
Param spar, mpar, dpar; Param spar, mpar, dpar;
int inuse; int inuse;
}; };
static Dbuf dbuf[10]; static Dbuf dbuf[10];
@ -1672,6 +1672,7 @@ readptr(Param *p, uint8_t *s, int y)
uint8_t *q; uint8_t *q;
USED(s); USED(s);
memset(&b, 0, sizeof(Buffer);
q = p->bytermin + y*p->bwidth; q = p->bytermin + y*p->bwidth;
b.red = q; /* ptr to data */ b.red = q; /* ptr to data */
b.grn = b.blu = b.grey = b.alpha = nil; b.grn = b.blu = b.grey = b.alpha = nil;