Add error handling in ?x-

This commit is contained in:
pancake 2018-09-02 15:58:13 +02:00
parent ce49c831b4
commit 1875a7f4f0
2 changed files with 16 additions and 8 deletions

View File

@ -786,9 +786,11 @@ int main(int argc, char **argv) {
}
break;
case 'h':
r_core_fini (&core);
return rabin_show_help (1);
default: action |= R_BIN_REQ_HELP;
r_core_fini (&core);
return rabin_show_help (1);
default:
action |= R_BIN_REQ_HELP;
break;
}
}

View File

@ -730,11 +730,17 @@ static int cmd_help(void *data, const char *input) {
case 'x': // "?x"
for (input++; input[0] == ' '; input++);
if (*input == '-') {
ut8 *out = malloc (strlen (input)+1);
int len = r_hex_str2bin (input+1, out);
out[len] = 0;
r_cons_println ((const char*)out);
free (out);
ut8 *out = malloc (strlen (input) + 1);
if (out) {
int len = r_hex_str2bin (input + 1, out);
if (len >= 0) {
out[len] = 0;
r_cons_println ((const char*)out);
} else {
eprintf ("Error parsing the hexpair string\n");
}
free (out);
}
} else if (*input == '+') {
ut64 n = r_num_math (core->num, input);
int bits = r_num_to_bits (NULL, n) / 8;