From 1ef8cbfe441999234e3cb1f6f4c6e74389ccb0f7 Mon Sep 17 00:00:00 2001 From: Allanis Date: Wed, 3 Apr 2013 17:24:06 +0100 Subject: [PATCH] [Fix] Attempting to kill some seg faults. --- src/hook.c | 2 +- src/toolkit.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/hook.c b/src/hook.c index 590a4b3..593b34e 100644 --- a/src/hook.c +++ b/src/hook.c @@ -72,7 +72,7 @@ void hook_rm(int id) { if(m == (hook_nstack-1)) return; // Move it! - memmove(&hook_stack[m+1], &hook_stack[m+2], hook_nstack-(m+1)); + memmove(&hook_stack[m+1], &hook_stack[m+2], sizeof(Hook)*(hook_nstack-(m+2))); hook_nstack--; } diff --git a/src/toolkit.c b/src/toolkit.c index 80c7b7a..88f67c2 100644 --- a/src/toolkit.c +++ b/src/toolkit.c @@ -573,9 +573,10 @@ void window_destroyWidget(unsigned int wid, const char* wgtname) { widget_cleanup(&w->widgets[i]); if(i < w->nwidgets-1) // This isn't the last widget. - w->widgets[i] = w->widgets[i-1]; + memmove(&w->widgets[i], &w->widgets[i+1], + sizeof(Widget) * (w->nwidgets-i-1)); - w->nwidgets--; // Not that we don't actually realloc the space.. + (w->nwidgets)--; // Not that we don't actually realloc the space.. } static void toolkit_drawOutline(double x, double y, double w, double h,