Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fail hard when the stream state is clobbered beyond repair

  • Loading branch information...
commit b85bbc9846c05278c386bf6032413ad1ab0581e9 1 parent 59bd396
Konstantin Käfer authored March 29, 2011

Showing 1 changed file with 4 additions and 6 deletions. Show diff stats Hide diff stats

  1. 10  src/node-zlib.cc
10  src/node-zlib.cc
@@ -46,6 +46,10 @@ Handle<Value> ZLib_##x##flate(const Arguments& args) {                         \
46 46
         return ZLib_error("Expected Buffer as first argument");                \
47 47
     }                                                                          \
48 48
                                                                                \
  49
+    if ((x##flateReset(&x##flate_s)) != Z_OK) {                                \
  50
+        assert((false, "ZLib stream is beyond repair"));                       \
  51
+    }                                                                          \
  52
+                                                                               \
49 53
     Local<Object> input = args[0]->ToObject();                                 \
50 54
     x##flate_s.next_in = (Bytef*)Buffer_Data(input);                           \
51 55
     int length = x##flate_s.avail_in = Buffer_Length(input);                   \
@@ -70,12 +74,6 @@ Handle<Value> ZLib_##x##flate(const Arguments& args) {                         \
70 74
         compressed += (factor * length - x##flate_s.avail_out);                \
71 75
     } while (x##flate_s.avail_out == 0);                                       \
72 76
                                                                                \
73  
-    ret = x##flateReset(&x##flate_s);                                          \
74  
-    if (ret != Z_OK) {                                                         \
75  
-        free(result);                                                          \
76  
-        return ZLib_error(x##flate_s.msg);                                     \
77  
-    }                                                                          \
78  
-                                                                               \
79 77
     Buffer* output = Buffer_New(result, compressed);                           \
80 78
     free(result);                                                              \
81 79
     return scope.Close(Local<Value>::New(output->handle_));                    \

0 notes on commit b85bbc9

Please sign in to comment.
Something went wrong with that request. Please try again.