Commit 386f34c7 authored by Kenton Varda's avatar Kenton Varda

Fix -fno-exceptions after bounded-types change.

parent 45442498
...@@ -1617,7 +1617,7 @@ struct WireHelpers { ...@@ -1617,7 +1617,7 @@ struct WireHelpers {
} }
} else { } else {
word* ptr = followFars(ref, refTarget, segment); word* ptr = followFars(ref, refTarget, segment);
char* cptr = reinterpret_cast<char*>(ptr); byte* bptr = reinterpret_cast<byte*>(ptr);
KJ_REQUIRE(ref->kind() == WirePointer::LIST, KJ_REQUIRE(ref->kind() == WirePointer::LIST,
"Called getText{Field,Element}() but existing pointer is not a list.") { "Called getText{Field,Element}() but existing pointer is not a list.") {
...@@ -1628,13 +1628,19 @@ struct WireHelpers { ...@@ -1628,13 +1628,19 @@ struct WireHelpers {
goto useDefault; goto useDefault;
} }
size_t size = unbound(subtractChecked(ref->listRef.elementCount() / ELEMENTS, ONE, auto maybeSize = trySubtract(ref->listRef.elementCount() * (ONE * BYTES / ELEMENTS),
[]() { KJ_FAIL_REQUIRE("zero-size blob can't be text (need NUL terminator)"); })); ONE * BYTES);
KJ_REQUIRE(cptr[size] == '\0', "Text blob missing NUL terminator.") { KJ_IF_MAYBE(size, maybeSize) {
goto useDefault; KJ_REQUIRE(*(bptr + *size) == '\0', "Text blob missing NUL terminator.") {
} goto useDefault;
}
return Text::Builder(cptr, size); return Text::Builder(reinterpret_cast<char*>(bptr), unbound(*size / BYTES));
} else {
KJ_FAIL_REQUIRE("zero-size blob can't be text (need NUL terminator)") {
goto useDefault;
};
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment