Index: src/runtime/static-instances.m ================================================================== --- src/runtime/static-instances.m +++ src/runtime/static-instances.m @@ -42,11 +42,11 @@ static_instances_cnt--; if (static_instances_cnt == 0) { free(static_instances); static_instances = NULL; - continue; + break; } static_instances[i] = static_instances[static_instances_cnt]; @@ -55,10 +55,16 @@ static_instances_cnt); if (static_instances == NULL) OBJC_ERROR("Not enough memory for list of " "static instances!"); + + /* + * We moved the last entry to the current index, + * therefore we need to run again for the current index. + */ + i--; } } si = (struct objc_abi_static_instances **) symtab->defs[symtab->cls_def_cnt + symtab->cat_def_cnt];