From ee679b73419bc813a4519348d984f2810d154eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludger=20Kr=C3=A4mer?= Date: Sun, 29 May 2016 12:25:22 +0200 Subject: [PATCH] [memorystream] remove unneeded eof handling --- src/parsing/streams.h | 21 +-------------------- src/scripting/abc_interpreter.cpp | 2 -- 2 files changed, 1 insertion(+), 22 deletions(-) diff --git a/src/parsing/streams.h b/src/parsing/streams.h index 24ec63a7cc..18607a37e8 100644 --- a/src/parsing/streams.h +++ b/src/parsing/streams.h @@ -101,14 +101,13 @@ class memorystream const char* const code; unsigned int len; unsigned int pos; - bool read_past_end; public: lightspark::method_body_info_cache* codecache; // Create a stream from a buffer b. // // The buffer is not copied, so b must continue to exists for // the life-time of this memorystream instance. - memorystream(const char* const b, unsigned int l,lightspark::method_body_info_cache* cc): code(b), len(l), pos(0), read_past_end(false),codecache(cc) {}; + memorystream(const char* const b, unsigned int l,lightspark::method_body_info_cache* cc): code(b), len(l), pos(0),codecache(cc) {}; static void handleError(const char *msg); inline unsigned int size() const { @@ -134,7 +133,6 @@ class memorystream { memcpy(out, code+pos, len-pos); pos = len; - read_past_end = true; } else { @@ -153,7 +151,6 @@ class memorystream else { pos = len; - read_past_end = true; return 0; } } @@ -163,11 +160,6 @@ class memorystream if (codecache[currpos].type == lightspark::method_body_info_cache::CACHE_TYPE_UINTEGER) { pos = codecache[currpos].nextpos; - if (pos > len) - { - pos = len; - read_past_end = true; - } return codecache[currpos].uvalue; } uint32_t val = readu32(); @@ -212,11 +204,6 @@ class memorystream if (codecache[currpos].type == lightspark::method_body_info_cache::CACHE_TYPE_INTEGER) { pos = codecache[currpos].nextpos; - if (pos > len) - { - pos = len; - read_past_end = true; - } return codecache[currpos].ivalue; } uint32_t val=0; @@ -227,11 +214,5 @@ class memorystream codecache[currpos].nextpos = pos; return ret; } - - inline bool eof() const - { - return read_past_end; - } - }; #endif /* PARSING_STREAMS_H */ diff --git a/src/scripting/abc_interpreter.cpp b/src/scripting/abc_interpreter.cpp index 8c84145da8..16c9e07887 100644 --- a/src/scripting/abc_interpreter.cpp +++ b/src/scripting/abc_interpreter.cpp @@ -66,8 +66,6 @@ ASObject* ABCVm::executeFunction(const SyntheticFunction* function, call_context uint32_t instructionPointer=code.tellg(); #endif opcode = code.readbyte(); - if(code.eof()) - throw ParseException("End of code in interpreter"); //Save ip for exception handling in SyntheticFunction::callImpl context->exec_pos = code.tellg();