X-Git-Url: https://git.saurik.com/cycript.git/blobdiff_plain/8409b00dd7d878ec81e49accdd902e441680424a..ed35b2d30b2d7f336d94bbab59f114a21064ad58:/Library.cpp diff --git a/Library.cpp b/Library.cpp index 47da272..174ca67 100644 --- a/Library.cpp +++ b/Library.cpp @@ -1,5 +1,5 @@ -/* Cycript - Optimizing JavaScript Compiler/Runtime - * Copyright (C) 2009-2015 Jay Freeman (saurik) +/* Cycript - The Truly Universal Scripting Language + * Copyright (C) 2009-2016 Jay Freeman (saurik) */ /* GNU Affero General Public License, Version 3 {{{ */ @@ -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);