Making asan no ops for OpenBSD (not supported) and few mem leaks fixes (#10842)

This commit is contained in:
David CARLIER 2018-07-29 09:43:46 +01:00 committed by Anton Kochkov
parent 5e56c90483
commit adaa0bc986
2 changed files with 8 additions and 0 deletions

View File

@ -936,6 +936,7 @@ R_API RAsmCode* r_asm_massemble(RAsm *a, const char *buf) {
ret = r_asm_pseudo_incbin (&op, ptr + 8);
} else {
eprintf ("Unknown directive (%s)\n", ptr);
free(lbuf);
return r_asm_code_free (acode);
}
if (!ret) {
@ -943,6 +944,7 @@ R_API RAsmCode* r_asm_massemble(RAsm *a, const char *buf) {
}
if (ret < 0) {
eprintf ("!!! Oops\n");
free(lbuf);
return r_asm_code_free (acode);
}
} else { /* Instruction */
@ -968,16 +970,19 @@ R_API RAsmCode* r_asm_massemble(RAsm *a, const char *buf) {
if (stage == STAGES - 1) {
if (ret < 1) {
eprintf ("Cannot assemble '%s' at line %d\n", ptr_start, linenum);
free(lbuf);
return r_asm_code_free (acode);
}
acode->len = idx + ret;
char *newbuf = realloc (acode->buf, (idx + ret) * 2);
if (!newbuf) {
free(lbuf);
return r_asm_code_free (acode);
}
acode->buf = (ut8*)newbuf;
newbuf = realloc (acode->buf_hex, strlen (acode->buf_hex) + strlen (op.buf_hex) + r_buf_size (op.buf_inc) + 1);
if (!newbuf) {
free(lbuf);
return r_asm_code_free (acode);
}
acode->buf_hex = newbuf;

View File

@ -265,6 +265,9 @@ def main():
parser.add_argument('--options', nargs='*', default=[])
args = parser.parse_args()
if args.asan:
if os.uname().sysname == 'OpenBSD':
log.error("Asan insupported under OpenBSD")
sys.exit(1)
cflags = os.environ.get('CFLAGS')
if not cflags:
cflags = ''