Permalink
Browse files

fail hard when the stream state is clobbered beyond repair

  • Loading branch information...
kkaefer committed Mar 29, 2011
1 parent 59bd396 commit b85bbc9846c05278c386bf6032413ad1ab0581e9
Showing with 4 additions and 6 deletions.
  1. +4 −6 src/node-zlib.cc
@@ -46,6 +46,10 @@ Handle<Value> ZLib_##x##flate(const Arguments& args) { \
return ZLib_error("Expected Buffer as first argument"); \
} \
\
if ((x##flateReset(&x##flate_s)) != Z_OK) { \
assert((false, "ZLib stream is beyond repair")); \
} \
\
Local<Object> input = args[0]->ToObject(); \
x##flate_s.next_in = (Bytef*)Buffer_Data(input); \
int length = x##flate_s.avail_in = Buffer_Length(input); \
@@ -70,12 +74,6 @@ Handle<Value> ZLib_##x##flate(const Arguments& args) { \
compressed += (factor * length - x##flate_s.avail_out); \
} while (x##flate_s.avail_out == 0); \
\
ret = x##flateReset(&x##flate_s); \
if (ret != Z_OK) { \
free(result); \
return ZLib_error(x##flate_s.msg); \
} \
\
Buffer* output = Buffer_New(result, compressed); \
free(result); \
return scope.Close(Local<Value>::New(output->handle_)); \

0 comments on commit b85bbc9

Please sign in to comment.