mirror of https://github.com/dynup/kpatch
Merge pull request #1246 from Decave/malloc_failure_check
kpatch-build: Add missing malloc failure check
This commit is contained in:
commit
b65fce5e07
|
@ -911,6 +911,8 @@ do { \
|
|||
log_debug("renaming %s %s to %s\n", \
|
||||
kindstr, e2->name, e1->name); \
|
||||
e2->name = strdup(e1->name); \
|
||||
if (!e2->name) \
|
||||
ERROR("strdup"); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
@ -3461,6 +3463,8 @@ static void kpatch_create_mcount_sections(struct kpatch_elf *kelf)
|
|||
|
||||
/* Make a writable copy of the text section data */
|
||||
newdata = malloc(sym->sec->data->d_size);
|
||||
if (!newdata)
|
||||
ERROR("malloc");
|
||||
memcpy(newdata, sym->sec->data->d_buf, sym->sec->data->d_size);
|
||||
sym->sec->data->d_buf = newdata;
|
||||
insn = newdata;
|
||||
|
|
|
@ -326,6 +326,8 @@ static void create_klp_arch_sections(struct kpatch_elf *kelf, char *strings)
|
|||
|
||||
new_size = old_size + base->data->d_size;
|
||||
sec->data->d_buf = realloc(sec->data->d_buf, new_size);
|
||||
if (!sec->data->d_buf)
|
||||
ERROR("realloc");
|
||||
sec->data->d_size = new_size;
|
||||
sec->sh.sh_size = sec->data->d_size;
|
||||
memcpy(sec->data->d_buf + old_size,
|
||||
|
|
Loading…
Reference in New Issue