Removed possible null dereference and one clang-analyzer warning squashed

This commit is contained in:
Mizari 2016-03-31 20:30:30 +06:00 committed by pancake
parent fa4edbfa45
commit 477986be2c

View File

@ -199,10 +199,17 @@ R_API int r_reg_arena_push(RReg *reg) {
int i;
for (i = 0; i < R_REG_TYPE_LAST; i++) {
RRegArena *a = reg->regset[i].arena; // current arena
if (!a) continue;
RRegArena *b = r_reg_arena_new (a->size); // new arena
if (!a || !b) continue;
if (!b) continue;
// if (!i) { r_print_hexdump (NULL, 0, a->bytes, a->size, 16, 16); }
memcpy (b->bytes, a->bytes, a->size);
if (a->size >= b->size) {
memcpy (b->bytes, a->bytes, b->size);
}
else {
memcpy (b->bytes, a->bytes, a->size);
memset (b->bytes + a->size, 0, b->size - a->size);
}
r_list_push (reg->regset[i].pool, b);
reg->regset[i].arena = b;
}