Fix #608 - Vv endless read #608

This commit is contained in:
pancake 2014-02-08 12:09:12 +01:00
parent 18d7167f63
commit 1f6ee6d546
4 changed files with 32 additions and 7 deletions

View File

@ -761,6 +761,7 @@ static void dump_r_bin_dwarf_debug_abbrev(FILE *f, RBinDwarfDebugAbbrev *da) {
R_API void r_bin_dwarf_free_debug_abbrev(RBinDwarfDebugAbbrev *da) {
size_t i;
if (!da) return;
for (i = 0; i < da->length; i++)
free(da->decls[i].specs);

View File

@ -99,6 +99,7 @@ R_API int r_core_visual_trackflags(RCore *core) {
}
r_cons_visual_flush ();
ch = r_cons_readchar ();
if (ch==-1||ch==4) return R_FALSE;
ch = r_cons_arrow_to_hjkl (ch); // get ESC+char, return 'hjkl' char
switch (ch) {
case 'J': option += 10; break;
@ -518,6 +519,8 @@ R_API void r_core_visual_config(RCore *core) {
r_core_cmd (core, "pd 5", 0);
r_cons_visual_flush ();
ch = r_cons_readchar ();
if (ch==4||ch==-1)
return;
ch = r_cons_arrow_to_hjkl (ch); // get ESC+char, return 'hjkl' char
switch (ch) {
@ -1037,6 +1040,12 @@ R_API void r_core_visual_anal(RCore *core) {
for (;;) {
r_core_visual_anal_refresh (core);
ch = r_cons_readchar ();
if (ch==4||ch==-1) {
if (level==0)
goto beach;
level--;
continue;
}
ch = r_cons_arrow_to_hjkl (ch); // get ESC+char, return 'hjkl' char
switch (ch) {
case '?':
@ -1060,7 +1069,7 @@ R_API void r_core_visual_anal(RCore *core) {
case 'a':
switch (level) {
case 0:
eprintf ("TODO: Add new function manually\n");
eprintf ("TODO: Add new function manually\n");
/*
r_cons_show_cursor (R_TRUE);
r_cons_set_raw (R_FALSE);

View File

@ -32,21 +32,26 @@ SDB_API char *sdb_querysf (Sdb *s, char *buf, size_t buflen, const char *fmt, ..
// XXX: cmd is reused
SDB_API char *sdb_querys (Sdb *s, char *buf, size_t len, const char *cmd) {
int i, d, ok, w, alength, bufset = 0;
const char *p, *q, *val = NULL;
char *eq, *ask;
int i, d, ok, w, alength;
ut64 n;
if (!s) return NULL;
if (cmd == NULL) {
cmd = buf;
buf = NULL;
}
if (!len || !buf) buf = malloc ((len=64));
if (!len || !buf) {
bufset = 1;
buf = malloc ((len=64));
}
ask = strchr (cmd, '?');
if (*cmd == '[') {
char *tp = strchr (cmd, ']');
if (!tp) {
fprintf (stderr, "Missing ']'.\n");
if (bufset)
free (buf);
return NULL;
}
*tp++ = 0;
@ -66,7 +71,9 @@ SDB_API char *sdb_querys (Sdb *s, char *buf, size_t len, const char *cmd) {
if (*cmd == '.') {
sdb_query_file (s, cmd+1);
return buf;
if (bufset)
free (buf);
return NULL;
} else
if (*cmd == '+' || *cmd == '-') {
d = 1;
@ -202,7 +209,11 @@ SDB_API char *sdb_querys (Sdb *s, char *buf, size_t len, const char *cmd) {
*ask++ = 0;
ok = sdb_json_set (s, cmd, ask, val, 0);
} else ok = sdb_set (s, cmd, val, 0);
if (!ok) return NULL;
if (!ok) {
if (bufset)
free (buf);
return NULL;
}
*buf = 0;
return buf;
} else {
@ -223,7 +234,8 @@ SDB_API char *sdb_querys (Sdb *s, char *buf, size_t len, const char *cmd) {
}
}
}
free (buf);
if (bufset)
free (buf);
return NULL;
}

View File

@ -581,7 +581,10 @@ SDB_API int sdb_hook(Sdb* s, SdbHook cb, void* user) {
return 0;
i++;
}
} else s->hooks = ls_new ();
} else {
s->hooks = ls_new ();
s->hooks->free = NULL;
}
ls_append (s->hooks, cb);
ls_append (s->hooks, user);
return 1;