Skip to content

Commit 0436db6

Browse files
committed
TH_GenericList: handle empty list directly.
1 parent 625bea8 commit 0436db6

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/TypeHandlers/TH_GenericList.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,13 @@ namespace tivars::TypeHandlers
2828
throw std::invalid_argument("Invalid type for given string");
2929
}
3030

31-
auto arr = explode(trim(str, "{}"), ',');
31+
const std::string inner = trim(str, "{}");
32+
if (inner.empty())
33+
{
34+
return {0, 0};
35+
}
36+
37+
auto arr = explode(inner, ',');
3238
const size_t numCount = arr.size();
3339

3440
for (auto& numStr : arr)
@@ -65,6 +71,10 @@ namespace tivars::TypeHandlers
6571
}
6672

6773
const size_t numCount = (size_t) ((data[0] & 0xFF) + ((data[1] & 0xFF) << 8));
74+
if (numCount == 0 && byteCount == 2)
75+
{
76+
return "{}";
77+
}
6878

6979
const bool isRealList = (numCount == (byteCount - 2) / TH_GenericReal::dataByteCount);
7080
const bool isComplexList = (numCount == (byteCount - 2) / TH_GenericComplex::dataByteCount);

0 commit comments

Comments
 (0)