Mercurial > repos > blastem
diff m68k_core.c @ 796:41f73c76b978
Fix some memory issues
author | =?UTF-8?q?Higor=20Eur=C3=ADpedes?= <heuripedes@gmail.com> |
---|---|
date | Sun, 26 Jul 2015 11:00:25 -0700 |
parents | 7367b14ac01c |
children | 0b692b5d154b |
line wrap: on
line diff
--- a/m68k_core.c Sun Jul 26 10:59:41 2015 -0700 +++ b/m68k_core.c Sun Jul 26 11:00:25 2015 -0700 @@ -1004,8 +1004,9 @@ m68k_context * init_68k_context(m68k_options * opts) { - m68k_context * context = malloc(sizeof(m68k_context) + ram_size(&opts->gen) / (1 << opts->gen.ram_flags_shift) / 8); - memset(context, 0, sizeof(m68k_context)); + size_t ctx_size = sizeof(m68k_context) + ram_size(&opts->gen) / (1 << opts->gen.ram_flags_shift) / 8; + m68k_context * context = malloc(ctx_size); + memset(context, 0, ctx_size); context->native_code_map = opts->gen.native_code_map; context->options = opts; context->int_cycle = CYCLE_NEVER;