diff options
author | Haru <haru@dotalux.com> | 2015-05-19 01:59:33 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2015-05-19 03:08:22 +0200 |
commit | bd2109d614a443045c7bbbf632bb9035216e3623 (patch) | |
tree | 2e125e4ce2b6a8c60b5e2303b1e2b0a88386ff70 /src/map/pc.c | |
parent | 6ac5a0ccfb601b81e1b84f6e86175d40bb16864b (diff) | |
download | hercules-bd2109d614a443045c7bbbf632bb9035216e3623.tar.gz hercules-bd2109d614a443045c7bbbf632bb9035216e3623.tar.bz2 hercules-bd2109d614a443045c7bbbf632bb9035216e3623.tar.xz hercules-bd2109d614a443045c7bbbf632bb9035216e3623.zip |
Fixed some issues reported by coverity scan [3/3]
- Automatically zeroed variables are now zeroed in the correct size,
regardless of padding.
- Special thanks to Ind.
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/pc.c')
-rw-r--r-- | src/map/pc.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/map/pc.c b/src/map/pc.c index 7ae446c90..5fc6469f3 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -11047,16 +11047,10 @@ void pc_defaults(void) { /* */ pc->day_timer_tid = INVALID_TIMER; pc->night_timer_tid = INVALID_TIMER; - /* respecting order */ - memset(pc->exp_table, 0, sizeof(pc->exp_table) - + sizeof(pc->max_level) - + sizeof(pc->statp) - + sizeof(pc->level_penalty) - + sizeof(pc->skill_tree) - + sizeof(pc->smith_fame_list) - + sizeof(pc->chemist_fame_list) - + sizeof(pc->taekwon_fame_list) - ); + + // These macros are used instead of a sum of sizeof(), to ensure that padding won't interfere with our size, and code won't rot when adding more fields + memset(ZEROED_BLOCK_POS(pc), 0, ZEROED_BLOCK_SIZE(pc)); + /* */ memcpy(pc->equip_pos, &equip_pos, sizeof(pc->equip_pos)); /* */ |