From 3f2a69f8ca59e412d9bb608b504703be97ed1942 Mon Sep 17 00:00:00 2001 From: Nunuhara Cabbage Date: Fri, 15 Nov 2019 19:33:56 -0800 Subject: [PATCH] aindump: fix crash when dumping HLL functions HLL functions can accept struct arguments, although there is no way to determine the struct type other than analysing the code. --- ain.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ain.c b/ain.c index ce98417..03063ec 100644 --- a/ain.c +++ b/ain.c @@ -52,23 +52,32 @@ const char *ain_strtype(struct ain *ain, enum ain_data_type type, int struct_typ case AIN_INT: return "int"; case AIN_FLOAT: return "float"; case AIN_STRING: return "string"; - case AIN_STRUCT: return ain->structures[struct_type].name; + case AIN_STRUCT: + if (struct_type == -1) + return "struct"; + return ain->structures[struct_type].name; case AIN_ARRAY_INT: return "array@int"; case AIN_ARRAY_FLOAT: return "array@float"; case AIN_ARRAY_STRING: return "array@string"; case AIN_ARRAY_STRUCT: + if (struct_type == -1) + return "array@struct"; snprintf(buf, 1023, "array@%s", ain->structures[struct_type].name); return buf; case AIN_REF_INT: return "ref int"; case AIN_REF_FLOAT: return "ref float"; case AIN_REF_STRING: return "ref string"; case AIN_REF_STRUCT: + if (struct_type == -1) + return "ref struct"; snprintf(buf, 1023, "ref %s", ain->structures[struct_type].name); return buf; case AIN_REF_ARRAY_INT: return "ref array@int"; case AIN_REF_ARRAY_FLOAT: return "ref array@float"; case AIN_REF_ARRAY_STRING: return "ref array@string"; case AIN_REF_ARRAY_STRUCT: + if (struct_type == -1) + return "ref array@struct"; snprintf(buf, 1023, "ref array@%s", ain->structures[struct_type].name); return buf; case AIN_IMAIN_SYSTEM: return "imain_system";