diff --git a/tools/wrc/genres.c b/tools/wrc/genres.c index afce7d91faf..bb46d98f684 100644 --- a/tools/wrc/genres.c +++ b/tools/wrc/genres.c @@ -51,6 +51,7 @@ res_t *new_res(void) r = (res_t *)xmalloc(sizeof(res_t)); r->allocsize = RES_BLOCKSIZE; r->size = 0; + r->dataidx = 0; r->data = (char *)xmalloc(RES_BLOCKSIZE); return r; } diff --git a/tools/wrc/newstruc.c b/tools/wrc/newstruc.c index c729a594f4f..60356081d76 100644 --- a/tools/wrc/newstruc.c +++ b/tools/wrc/newstruc.c @@ -76,6 +76,7 @@ __NEW_STRUCT_FUNC(ani_any) resource_t *new_resource(enum res_e t, void *res, int memopt, language_t *lan) { resource_t *r = (resource_t *)xmalloc(sizeof(resource_t)); + memset( r, 0, sizeof(*r) ); r->type = t; r->res.overlay = res; r->memopt = memopt; @@ -1145,6 +1146,7 @@ stringtable_t *new_stringtable(lvc_t *lvc) { stringtable_t *stt = (stringtable_t *)xmalloc(sizeof(stringtable_t)); + memset( stt, 0, sizeof(*stt) ); if(lvc) stt->lvc = *lvc; @@ -1154,6 +1156,7 @@ stringtable_t *new_stringtable(lvc_t *lvc) toolbar_t *new_toolbar(int button_width, int button_height, toolbar_item_t *items, int nitems) { toolbar_t *tb = (toolbar_t *)xmalloc(sizeof(toolbar_t)); + memset( tb, 0, sizeof(*tb) ); tb->button_width = button_width; tb->button_height = button_height; tb->nitems = nitems; diff --git a/tools/wrc/newstruc.h b/tools/wrc/newstruc.h index 299782cc95d..2e46b144035 100644 --- a/tools/wrc/newstruc.h +++ b/tools/wrc/newstruc.h @@ -26,7 +26,9 @@ #define __NEW_STRUCT_FUNC(p) \ p##_t *new_##p(void)\ {\ - return (p##_t *)xmalloc(sizeof(p##_t));\ + p##_t * ret = xmalloc(sizeof(*ret)); \ + memset( ret, 0, sizeof(*ret) ); \ + return ret; \ } #define __NEW_STRUCT_PROTO(p) p##_t *new_##p(void) diff --git a/tools/wrc/parser.y b/tools/wrc/parser.y index 252606cd64f..a903823adf8 100644 --- a/tools/wrc/parser.y +++ b/tools/wrc/parser.y @@ -2286,6 +2286,7 @@ static event_t *add_string_event(string_t *key, int id, int flags, event_t *prev static itemex_opt_t *new_itemex_opt(int id, int type, int state, int helpid) { itemex_opt_t *opt = (itemex_opt_t *)xmalloc(sizeof(itemex_opt_t)); + memset( opt, 0, sizeof(*opt) ); opt->id = id; opt->type = type; opt->state = state; @@ -2602,6 +2603,7 @@ static resource_t *build_stt_resources(stringtable_t *stthead) { newstt = new_stringtable(&stt->lvc); newstt->entries = (stt_entry_t *)xmalloc(16 * sizeof(stt_entry_t)); + memset( newstt->entries, 0, 16 * sizeof(stt_entry_t) ); newstt->nentries = 16; newstt->idbase = stt->entries[i].id & ~0xf; for(j = 0; j < 16 && i < stt->nentries; j++) @@ -2823,6 +2825,7 @@ static resource_t *build_fontdirs(resource_t *tail) /* Copy space */ lanfnt = xmalloc(nfnt * sizeof(*lanfnt)); + memset( lanfnt, 0, nfnt * sizeof(*lanfnt)); /* Get all fonts covered by fontdirs */ for(i = 0; i < nfnd; i++) diff --git a/tools/wrc/utils.c b/tools/wrc/utils.c index f0e29326156..d8ab8e9dfae 100644 --- a/tools/wrc/utils.c +++ b/tools/wrc/utils.c @@ -168,12 +168,7 @@ void *xmalloc(size_t size) { error("Virtual memory exhausted.\n"); } - /* - * We set it to 0. - * This is *paramount* because we depend on it - * just about everywhere in the rest of the code. - */ - memset(res, 0, size); + memset(res, 0x55, size); return res; }