Fix #6715 - NULL dereference

This commit is contained in:
alvarofe 2017-02-12 13:05:47 +01:00
parent 2a80733253
commit f52b631568
2 changed files with 9 additions and 4 deletions

View File

@ -24,7 +24,9 @@ R_API char *r_bin_addr2text(RBin *bin, ut64 addr, int origin) {
int line;
char *out = NULL, *out2 = NULL;
char *file_nopath = NULL;
if (!bin || !bin->cur) {
return NULL;
}
{
char *key = r_str_newf ("0x%"PFMT64x, addr);
char *file_line = sdb_get (bin->cur->sdb_addrinfo, key, 0);

View File

@ -282,10 +282,13 @@ R_API int r_buf_set_bits(RBuffer *b, int bitoff, int bitsize, ut64 value) {
}
R_API int r_buf_set_bytes(RBuffer *b, const ut8 *buf, ut64 length) {
if (length <= 0 || !buf) return false;
free (b->buf);
if (!(b->buf = malloc (length)))
if (length <= 0 || !buf) {
return false;
}
free (b->buf);
if (!(b->buf = malloc (length))) {
return false;
}
memmove (b->buf, buf, length);
b->length = length;