Mercurial > repos > blastem
comparison vdp.c @ 2494:b62580dc6f30
Fix kmod buffer storage bug
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 28 Apr 2024 23:18:53 -0700 |
parents | cf3e8a19aa25 |
children | fa49e06d8c92 |
comparison
equal
deleted
inserted
replaced
2493:b62336ceb626 | 2494:b62580dc6f30 |
---|---|
4690 } else if (reg == REG_KMOD_MSG) { | 4690 } else if (reg == REG_KMOD_MSG) { |
4691 char c = value; | 4691 char c = value; |
4692 if (c) { | 4692 if (c) { |
4693 context->kmod_buffer_length++; | 4693 context->kmod_buffer_length++; |
4694 if ((context->kmod_buffer_length + 1) > context->kmod_buffer_storage) { | 4694 if ((context->kmod_buffer_length + 1) > context->kmod_buffer_storage) { |
4695 context->kmod_buffer_storage = context->kmod_buffer_length ? 128 : context->kmod_buffer_length * 2; | 4695 context->kmod_buffer_storage = context->kmod_buffer_storage ? context->kmod_buffer_storage * 2 : 128; |
4696 context->kmod_msg_buffer = realloc(context->kmod_msg_buffer, context->kmod_buffer_storage); | 4696 context->kmod_msg_buffer = realloc(context->kmod_msg_buffer, context->kmod_buffer_storage); |
4697 } | 4697 } |
4698 context->kmod_msg_buffer[context->kmod_buffer_length - 1] = c; | 4698 context->kmod_msg_buffer[context->kmod_buffer_length - 1] = c; |
4699 } else if (context->kmod_buffer_length) { | 4699 } else if (context->kmod_buffer_length) { |
4700 context->kmod_msg_buffer[context->kmod_buffer_length] = 0; | 4700 context->kmod_msg_buffer[context->kmod_buffer_length] = 0; |