Fix two more segfaults reported by zlul

This commit is contained in:
pancake 2013-11-14 04:15:40 +01:00
parent 816560dffe
commit 5ecf422335
1 changed files with 5 additions and 3 deletions

View File

@ -18,9 +18,11 @@ R_API int r_core_yank_set (RCore *core, const char *str) {
R_API int r_core_yank(struct r_core_t *core, ut64 addr, int len) {
ut64 oldbsz = 0LL;
ut64 curseek = core->offset;
free (core->yank_buf);
if (len<0)
if (len<0) {
eprintf ("r_core_yank: cannot yank negative bytes\n");
return R_FALSE;
}
free (core->yank_buf);
core->yank_buf = (ut8 *)malloc (len);
if (addr != core->offset)
r_core_seek (core, addr, 1);
@ -30,7 +32,7 @@ R_API int r_core_yank(struct r_core_t *core, ut64 addr, int len) {
} else
if (len > core->blocksize) {
oldbsz = core->blocksize;
r_core_block_size (core, len);
len = r_core_block_size (core, len);
}
memcpy (core->yank_buf, core->block, len);
core->yank_off = addr;