json: write null on abnormal placeholder destruction

Avoids leaving dangling attributes like

    {
        "foo":
    }

in case of exceptions.
This commit is contained in:
Naïm Favier 2022-08-19 00:59:04 +02:00
parent 7aa36ae796
commit 8188b1d0ab
No known key found for this signature in database
GPG key ID: 95AFCE8211908325

View file

@ -193,7 +193,11 @@ JSONObject JSONPlaceholder::object()
JSONPlaceholder::~JSONPlaceholder()
{
assert(!first || std::uncaught_exceptions());
if (first) {
assert(std::uncaught_exceptions());
if (state->stack != 0)
write(nullptr);
}
}
}