зеркало из https://github.com/github/ruby.git
* gc.c (rb_gc_unprotect_logging): throw rb_memerror when it cannot
allocate memory. This is pointed out by Facebook's Infer. * gc.c (gc_prof_setup_new_record): ditto. * regparse.c (parse_regexp): ditto. * util.c (MALLOC): use xmalloc and xfree like above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54954 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
6db71fb11a
Коммит
b3935f179b
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
Mon May 9 02:51:51 2016 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
|
* gc.c (rb_gc_unprotect_logging): throw rb_memerror when it cannot
|
||||||
|
allocate memory. This is pointed out by Facebook's Infer.
|
||||||
|
|
||||||
|
* gc.c (gc_prof_setup_new_record): ditto.
|
||||||
|
|
||||||
|
* regparse.c (parse_regexp): ditto.
|
||||||
|
|
||||||
|
* util.c (MALLOC): use xmalloc and xfree like above.
|
||||||
|
|
||||||
Mon May 9 02:39:16 2016 NARUSE, Yui <naruse@ruby-lang.org>
|
Mon May 9 02:39:16 2016 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* configure.in: check function attirbute const and pure,
|
* configure.in: check function attirbute const and pure,
|
||||||
|
|
6
gc.c
6
gc.c
|
@ -5962,6 +5962,7 @@ rb_gc_unprotect_logging(void *objptr, const char *filename, int line)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ptr = (char *)malloc(strlen(buff) + 1);
|
ptr = (char *)malloc(strlen(buff) + 1);
|
||||||
|
if (!ptr) rb_memerror();
|
||||||
strcpy(ptr, buff);
|
strcpy(ptr, buff);
|
||||||
}
|
}
|
||||||
st_insert(rgengc_unprotect_logging_table, (st_data_t)ptr, cnt);
|
st_insert(rgengc_unprotect_logging_table, (st_data_t)ptr, cnt);
|
||||||
|
@ -8523,8 +8524,11 @@ gc_prof_setup_new_record(rb_objspace_t *objspace, int reason)
|
||||||
objspace->profile.records = malloc(sizeof(gc_profile_record) * objspace->profile.size);
|
objspace->profile.records = malloc(sizeof(gc_profile_record) * objspace->profile.size);
|
||||||
}
|
}
|
||||||
if (index >= objspace->profile.size) {
|
if (index >= objspace->profile.size) {
|
||||||
|
void *ptr;
|
||||||
objspace->profile.size += 1000;
|
objspace->profile.size += 1000;
|
||||||
objspace->profile.records = realloc(objspace->profile.records, sizeof(gc_profile_record) * objspace->profile.size);
|
ptr = realloc(objspace->profile.records, sizeof(gc_profile_record) * objspace->profile.size);
|
||||||
|
if (!ptr) rb_memerror();
|
||||||
|
objspace->profile.records = ptr;
|
||||||
}
|
}
|
||||||
if (!objspace->profile.records) {
|
if (!objspace->profile.records) {
|
||||||
rb_bug("gc_profile malloc or realloc miss");
|
rb_bug("gc_profile malloc or realloc miss");
|
||||||
|
|
|
@ -6460,7 +6460,10 @@ parse_regexp(Node** top, UChar** src, UChar* end, ScanEnv* env)
|
||||||
NENCLOSE(np)->regnum = num;
|
NENCLOSE(np)->regnum = num;
|
||||||
NENCLOSE(np)->target = *top;
|
NENCLOSE(np)->target = *top;
|
||||||
r = scan_env_set_mem_node(env, num, np);
|
r = scan_env_set_mem_node(env, num, np);
|
||||||
if (r != 0) return r;
|
if (r != 0) {
|
||||||
|
onig_node_free(np);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
*top = np;
|
*top = np;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
4
util.c
4
util.c
|
@ -748,12 +748,12 @@ ruby_getcwd(void)
|
||||||
#ifdef MALLOC
|
#ifdef MALLOC
|
||||||
extern void *MALLOC(size_t);
|
extern void *MALLOC(size_t);
|
||||||
#else
|
#else
|
||||||
#define MALLOC malloc
|
#define MALLOC xmalloc
|
||||||
#endif
|
#endif
|
||||||
#ifdef FREE
|
#ifdef FREE
|
||||||
extern void FREE(void*);
|
extern void FREE(void*);
|
||||||
#else
|
#else
|
||||||
#define FREE free
|
#define FREE xfree
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef Omit_Private_Memory
|
#ifndef Omit_Private_Memory
|
||||||
|
|
Загрузка…
Ссылка в новой задаче