Fix #588 drx segfault

This commit is contained in:
pancake 2014-01-12 02:16:56 +01:00
parent c56bb2cd29
commit e7783173c7
3 changed files with 13 additions and 6 deletions

View File

@ -2622,14 +2622,15 @@ static int r_debug_native_drx(RDebug *dbg, int n, ut64 addr, int sz, int rwx, in
regs[2] = r_reg_getv (R, "dr2");
regs[3] = r_reg_getv (R, "dr3");
/*
RESERVED
regs[4] = r_reg_getv (R, "dr4");
regs[5] = r_reg_getv (R, "dr5");
regs[6] = r_reg_getv (R, "dr6");
*/
regs[6] = r_reg_getv (R, "dr6");
regs[7] = r_reg_getv (R, "dr7");
if (sz == 0) {
drx_list (regs);
drx_list (&regs);
return R_FALSE;
} else
if (sz<0) {

View File

@ -144,7 +144,8 @@ int drx_next(drxt *drx) {
void drx_list(drxt *drx) {
ut64 addr;
int i, rwx, len, g, en;
for(i=0; i<4; i++) {
for(i=0; i<7; i++) {
rwx = len = g = en = 0;
addr = drx_get (drx, i, &rwx, &len, &g, &en);
printf ("%c dr%d %c%c 0x%08"PFMT64x" %d\n",
en?'*':'-', i, g?'G':'L',

View File

@ -244,8 +244,10 @@ R_API int r_str_word_set0(char *str) {
if (!str || !*str)
return 0;
for (i=0; str[i] && str[i+1]; i++) {
if (str[i]==' ' && str[i+1]==' ')
memmove (str+i, str+i+1, strlen (str+1)+1);
if (str[i]==' ' && str[i+1]==' ') {
int len = strlen (str+i+1)+1;
memmove (str+i, str+i+1, len);
}
}
if (str[i]==' ')
str[i] = 0;
@ -532,9 +534,12 @@ R_API char *r_str_ndup(const char *ptr, int len) {
// TODO: deprecate?
R_API char *r_str_dup(char *ptr, const char *string) {
int len;
if (ptr) free (ptr);
if (!string) return NULL;
ptr = strdup (string);
len = strlen (string)+1;
ptr = malloc (len+1);
memcpy (ptr, string, len);
return ptr;
}