builtin/show-branch: rewrite functions to work with object_id
[gitweb.git] / streaming.c
index d7c9f32f0ce98112ddd4d4a8499b227b181e09e6..811fcc24d2a8ba56c233ae4e37b7acac29a4a0d8 100644 (file)
@@ -152,8 +152,10 @@ struct git_istream *open_istream(const unsigned char *sha1,
        if (filter) {
                /* Add "&& !is_null_stream_filter(filter)" for performance */
                struct git_istream *nst = attach_stream_filter(st, filter);
-               if (!nst)
+               if (!nst) {
                        close_istream(st);
+                       return NULL;
+               }
                st = nst;
        }
 
@@ -505,8 +507,11 @@ int stream_blob_to_fd(int fd, unsigned const char *sha1, struct stream_filter *f
        int result = -1;
 
        st = open_istream(sha1, &type, &sz, filter);
-       if (!st)
+       if (!st) {
+               if (filter)
+                       free_stream_filter(filter);
                return result;
+       }
        if (type != OBJ_BLOB)
                goto close_and_exit;
        for (;;) {