{"issue":{"title":"gzip.deflate memory leak","user":{"id":1276418,"login":"dmich","url":"https://api.github.com/users/dmich","gravatar_id":"d3cf7a2ef58e903c1c80ebf6f43a3013","avatar_url":"https://secure.gravatar.com/avatar/d3cf7a2ef58e903c1c80ebf6f43a3013?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"milestone":null,"created_at":"2011-12-21T00:50:07Z","labels":[],"state":"open","updated_at":"2011-12-22T17:43:38Z","id":2620373,"html_url":"https://github.com/waveto/node-compress/issues/14","closed_at":null,"pull_request":{"patch_url":null,"html_url":null,"diff_url":null},"body":"we see a memory leaks in gzip.deflate. Are there any known issues?\r\nAlso question (why you never delete the temporary buffer allocated at line 154?)\r\n        154 \tchar* buf = new char[len];\r\n\t155 \tssize_t written = DecodeWrite(buf, len, args[0], enc);\r\n\t156 \tassert(written == len);\r\n\t157 \t\r\n\t158 \tchar* out;\r\n\t159 \tint out_size;\r\n\t160 \tint r = gzip->GzipDeflate(buf, len, &out, &out_size);\r\n\t161 \t\r\n\t162 \tif (out_size==0) {\r\n\t163 \treturn scope.Close(String::New(\"\"));\r\n\t164 \t}\r\n\t165 \t\r\n\t166 \tLocal<Value> outString = Encode(out, out_size, BINARY);\r\n\t167 \tfree(out);\r\n\t168 \treturn scope.Close(outString);","number":14,"url":"https://api.github.com/repos/waveto/node-compress/issues/14","comments":1,"assignee":null},"comment":{"user":{"id":1276418,"login":"dmich","url":"https://api.github.com/users/dmich","gravatar_id":"d3cf7a2ef58e903c1c80ebf6f43a3013","avatar_url":"https://secure.gravatar.com/avatar/d3cf7a2ef58e903c1c80ebf6f43a3013?d=https://a248.e.akamai.net/assets.github.com%2Fimages%2Fgravatars%2Fgravatar-140.png"},"created_at":"2011-12-22T17:43:38Z","updated_at":"2011-12-22T17:43:38Z","id":3251965,"body":"fix:\r\n\r\n    char* buf = new char[len];\r\n\r\n    if(buf == NULL){\r\n      Local<Value> exception = Exception::TypeError(String::New(\"Out of memory\"));\r\n      return ThrowException(exception);\r\n    }\r\n\r\n    ssize_t written = DecodeWrite(buf, len, args[0], enc);\r\n    assert(written == len);\r\n\r\n    char* out;\r\n    int out_size;\r\n    int r = gzip->GzipDeflate(buf, len, &out, &out_size);\r\n\r\n    if (out_size==0) {\r\n        if(out != NULL)\r\n          free(out);\r\n        if(buf != NULL)\r\n          delete buf;\r\n      return scope.Close(String::New(\"\"));\r\n    }\r\n\r\n    Local<Value> outString = Encode(out, out_size, BINARY);\r\n\r\n    if(out != NULL)\r\n      free(out);\r\n    if(buf != NULL)\r\n      delete buf;\r\n\r\n    return scope.Close(outString);\r\n  }","url":"https://api.github.com/repos/waveto/node-compress/issues/comments/3251965"},"action":"created"}