fix: hc-gen segment fault when decompile empty array

Signed-off-by: yuanbo <yuanbo@huawei.com>
This commit is contained in:
yuanbo
2022-02-16 10:41:24 +08:00
parent 32b4218800
commit c5df2938c5
+8 -6
View File
@@ -72,15 +72,17 @@ int32_t DecompileGen::PrintArrayType(const std::shared_ptr<AstObject>& astObj)
{
WriteFile("[");
auto arrayElement = astObj->Child();
while (arrayElement->Next()) {
if (arrayElement != nullptr) {
while (arrayElement->Next()) {
if (PrintBaseType(arrayElement) != NOERR) {
return EOUTPUT;
}
WriteFile(", ");
arrayElement = arrayElement->Next();
}
if (PrintBaseType(arrayElement) != NOERR) {
return EOUTPUT;
}
WriteFile(", ");
arrayElement = arrayElement->Next();
}
if (PrintBaseType(arrayElement) != NOERR) {
return EOUTPUT;
}
WriteFile("]");
return NOERR;