don't abort when parsing malformed UTF8 strings

Previously, we would abort the process if we encountered a truncated
multibyte character in parseUtf8NonAscii (called by the JNI method
NewStringUTF).  Now we simply terminate the string at that point.
This commit is contained in:
Joel Dice 2011-04-07 14:26:54 -06:00
parent b0ae6343ad
commit af9288f4ee
2 changed files with 4 additions and 9 deletions

View File

@ -718,7 +718,6 @@ parseUtf8NonAscii(Thread* t, Stream& s, object bytesSoFar, unsigned byteCount,
value = v; value = v;
} }
charArrayBody(t, value, vi) = 0;
return value; return value;
} }
@ -4239,8 +4238,8 @@ parseUtf8(Thread* t, const char* data, unsigned length)
public: public:
Client(Thread* t): t(t) { } Client(Thread* t): t(t) { }
virtual void NO_RETURN handleError() { virtual void handleError() {
vm::abort(t); // vm::abort(t);
} }
private: private:

View File

@ -19,7 +19,7 @@ class Stream {
public: public:
class Client { class Client {
public: public:
virtual void NO_RETURN handleError() = 0; virtual void handleError() = 0;
}; };
Stream(Client* client, const uint8_t* data, unsigned size): Stream(Client* client, const uint8_t* data, unsigned size):
@ -44,11 +44,7 @@ class Stream {
void read(uint8_t* data, unsigned size) { void read(uint8_t* data, unsigned size) {
if (size > this->size - position_) { if (size > this->size - position_) {
// GCC 4.4 will give us an uninitialized value warning in read1 memset(data, 0, size);
// unless we do this: (it's smart enough to track data flow
// across functions but not smart enough to see we won't return
// from Client::handleError)
*data = 0;
client->handleError(); client->handleError();
} else { } else {