From 0a9f71790bcad2c6ffdc96db59c446fe84336d40 Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Sun, 12 Feb 2017 20:28:53 -0500 Subject: xworld: fix several horrendous bugs - unregisters timer on exit, preventing possible crash - disables synchronization mechanisms when used from an IRQ - prevents memory allocations from overflowing the audio buffer (unlikely) Change-Id: I3c2c4ebe93c10ca9176ed0455e7aacc2d10c059e --- apps/plugins/xworld/sys.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/plugins/xworld/sys.c b/apps/plugins/xworld/sys.c index b13d4fb9ed..eac47e66f0 100644 --- a/apps/plugins/xworld/sys.c +++ b/apps/plugins/xworld/sys.c @@ -117,6 +117,7 @@ void exit_handler(void) { sys_save_settings(save_sys); sys_stopAudio(save_sys); + rb->timer_unregister(); #ifdef HAVE_ADJUSTABLE_CPU_FREQ rb->cpu_boost(false); #endif @@ -1114,7 +1115,8 @@ void *sys_get_buffer(struct System* sys, size_t sz) { void* ret = sys->membuf; rb->memset(ret, 0, sz); - sys->membuf += sz; + sys->membuf = (char*)(sys->membuf) + sz; + sys->bytes_left -= sz; return ret; } else @@ -1128,11 +1130,12 @@ void MutexStack(struct MutexStack_t* s, struct System *stub, void *mutex) { s->sys = stub; s->_mutex = mutex; - sys_lockMutex(s->sys, s->_mutex); + /* FW 2017-2-12: disabled; no blocking ops in IRQ context! */ + /*sys_lockMutex(s->sys, s->_mutex);*/ } void MutexStack_destroy(struct MutexStack_t* s) { - sys_unlockMutex(s->sys, s->_mutex); - + (void) s; + /*sys_unlockMutex(s->sys, s->_mutex);*/ } -- cgit v1.2.3