From aa5434a48758e94efdf01d68fd98c0a9b03c8740 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Thu, 15 Feb 2018 14:40:29 +0100 Subject: [PATCH] Fix segfault in tj if size is not in sdb (#9400) --- libr/core/cmd_type.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libr/core/cmd_type.c b/libr/core/cmd_type.c index 31263b0b53..85bd52cf55 100644 --- a/libr/core/cmd_type.c +++ b/libr/core/cmd_type.c @@ -320,9 +320,10 @@ static int sdbforcb_default (void *p, const char *k, const char *v) { static int sdbforcb_json (void *p, const char *k, const char *v) { Sdb *sdb = (Sdb *)p; char *sizecmd = r_str_newf ("type.%s.size", k); + char *size_s = sdb_querys (sdb, NULL, -1, sizecmd); char *formatcmd = r_str_newf ("type.%s", k); r_cons_printf ("{\"type\":\"%s\",\"size\":%d,\"format\":\"%s\"}", k, - atoi (sdb_querys (sdb, NULL, -1, sizecmd)), + size_s ? atoi (size_s) : -1, r_str_trim (sdb_querys (sdb, NULL, -1, formatcmd))); free (sizecmd); free (formatcmd);