fix memory unsafe

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@392 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-10-17 03:18:17 +00:00
parent 791960a128
commit ec86f5297e

View File

@@ -170,7 +170,8 @@ MwWidget MwVaListCreateWidget(MwClass widget_class, const char* name, MwWidget p
}
static void MwFreeWidget(MwWidget handle) {
int i;
int i;
MwWidget root = handle;
MwDispatch(handle, destroy);
@@ -178,6 +179,14 @@ static void MwFreeWidget(MwWidget handle) {
MwFreeWidget(handle->children[i]);
}
while(root->parent != NULL) root = root->parent;
for(i = 0; i < arrlen(root->tick_list); i++) {
if(handle == root->tick_list[i]) {
arrdel(root->tick_list, i);
i--;
}
}
free(handle->name);
MwLLDestroy(handle->lowlevel);
@@ -199,19 +208,9 @@ static void MwFreeWidget(MwWidget handle) {
}
void MwDestroyWidget(MwWidget handle) {
int i;
MwWidget root = handle;
if(handle->parent != NULL) {
arrput(handle->parent->destroy_queue, handle);
}
while(root->parent != NULL) root = root->parent;
for(i = 0; i < arrlen(root->tick_list); i++) {
if(handle == root->tick_list[i]) {
arrdel(root->tick_list, i);
i--;
}
}
}
void MwStep(MwWidget handle) {