зеркало из https://github.com/github/ruby.git
avoid passing NULL to memset
`GC::Profiler.enable; GC::Profiler.clear` tries to clear objspace->profile.records but it has never been allocated before. Thus the MEMCPY took NULL argument before this changeset. The objspace->profile.records is allocated appropriately elsewhere. Why not juts free it if any? That should work.
This commit is contained in:
Родитель
34e1079aef
Коммит
f95f07dad3
14
gc.c
14
gc.c
|
@ -10476,16 +10476,14 @@ static VALUE
|
||||||
gc_profile_clear(void)
|
gc_profile_clear(void)
|
||||||
{
|
{
|
||||||
rb_objspace_t *objspace = &rb_objspace;
|
rb_objspace_t *objspace = &rb_objspace;
|
||||||
if (GC_PROFILE_RECORD_DEFAULT_SIZE * 2 < objspace->profile.size) {
|
void *p = objspace->profile.records;
|
||||||
objspace->profile.size = GC_PROFILE_RECORD_DEFAULT_SIZE * 2;
|
objspace->profile.records = NULL;
|
||||||
objspace->profile.records = realloc(objspace->profile.records, sizeof(gc_profile_record) * objspace->profile.size);
|
objspace->profile.size = 0;
|
||||||
if (!objspace->profile.records) {
|
|
||||||
rb_memerror();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MEMZERO(objspace->profile.records, gc_profile_record, objspace->profile.size);
|
|
||||||
objspace->profile.next_index = 0;
|
objspace->profile.next_index = 0;
|
||||||
objspace->profile.current_record = 0;
|
objspace->profile.current_record = 0;
|
||||||
|
if (p) {
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче