diff --git a/libr/core/core.c b/libr/core/core.c index de869c7ee8..1569feea87 100644 --- a/libr/core/core.c +++ b/libr/core/core.c @@ -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';