Fix glitch in some graph shortcuts (#12445)

This commit is contained in:
radare 2018-12-10 18:19:00 +01:00 committed by GitHub
parent e5c14c167b
commit ff87cc8029
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -174,7 +174,7 @@ R_API char* r_core_add_asmqjmp(RCore *core, ut64 addr) {
}
}
if (core->asmqjmps_count < core->asmqjmps_size - 1) {
int i;
int i = 0;
char t[R_CORE_ASMQJMPS_LEN_LETTERS + 1] = {0};
for (i = 0; i < core->asmqjmps_count + 1; i++) {
if (core->asmqjmps[i] == addr) {
@ -186,6 +186,10 @@ R_API char* r_core_add_asmqjmp(RCore *core, ut64 addr) {
i = ++core->asmqjmps_count;
core->asmqjmps[i] = addr;
}
// This check makes pos never be <1, thefor not fill 't' with trash
if (i < 1) {
return NULL;
}
r_core_set_asmqjmps (core, t, sizeof (t), i);
return strdup (t);
}
@ -203,15 +207,14 @@ R_API void r_core_set_asmqjmps(RCore *core, char *str, size_t len, int pos) {
pos --;
//// }
for (i = 0; i < R_CORE_ASMQJMPS_LEN_LETTERS - 1; i++) {
ut64 div = pos / letter_divs[i];
int div = pos / letter_divs[i];
pos %= letter_divs[i];
if (div > 0 && j < len) {
str[j] = 'A' + div - 1;
j++;
str[j++] = 'A' + div - 1;
}
}
if (j < len) {
ut64 div = pos % R_CORE_ASMQJMPS_LETTERS;
int div = pos % R_CORE_ASMQJMPS_LETTERS;
str[j++] = 'a' + div;
}
str[j] = '\0';