X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/8409b00dd7d878ec81e49accdd902e441680424a..824bc1ec28c62ea1d63622c46e1edfd911c38b64:/Library.cpp diff --git a/Library.cpp b/Library.cpp index 47da272..726f557 100644 --- a/Library.cpp +++ b/Library.cpp @@ -43,7 +43,7 @@ CYUTF8String CYPoolUTF8String(CYPool &pool, CYUTF16String utf16) { // XXX: this is wrong size_t size(utf16.size * 5); - char *temp(new(pool) char[size]); + char *temp(new(pool) char[size + 1]); const uint16_t *lhs(utf16.data); uint8_t *rhs(reinterpret_cast(temp)); @@ -56,7 +56,7 @@ CYUTF8String CYPoolUTF8String(CYPool &pool, CYUTF16String utf16) { CYUTF16String CYPoolUTF16String(CYPool &pool, CYUTF8String utf8) { // XXX: this is wrong size_t size(utf8.size * 5); - uint16_t *temp(new (pool) uint16_t[size]); + uint16_t *temp(new (pool) uint16_t[size + 1]); const uint8_t *lhs(reinterpret_cast(utf8.data)); uint16_t *rhs(temp); @@ -128,8 +128,12 @@ _visible bool CYStartsWith(const CYUTF8String &haystack, const CYUTF8String &nee CYUTF8String CYPoolCode(CYPool &pool, std::streambuf &stream) { CYLocalPool local; CYDriver driver(local, stream); - _assert(!driver.Parse()); - _assert(driver.errors_.empty()); + + if (driver.Parse()) { + if (!driver.errors_.empty()) + CYThrow("%s", driver.errors_.front().message_.c_str()); + CYThrow("syntax error"); + } CYOptions options; CYContext context(options);