open_istream(): do not dereference NULL in the error case

When stream-filter cannot be attached, it is expected to return NULL, and we should close the stream we opened and signal an error by returning NULL ourselves from this function. However, we attempted to dereference that NULL pointer between the point we detected the error and returned from the function. Brought-to-attention-by: John Keeping <john@keeping.me.uk> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano committed Feb 18, 2014 at 16:00 UTC 78368f2c1ad342719ccf1e719bd5126ca6c7b68b
1 file changed +3 -1
streaming.c
+3 -1
@@ -152,8 +152,10 @@ struct git_istream *open_istream(const unsigned char *sha1,
152 if (filter) {
153 /* Add "&& !is_null_stream_filter(filter)" for performance */
154 struct git_istream *nst = attach_stream_filter(st, filter);
155 - if (!nst)
155 + if (!nst) {
156 close_istream(st);
157 + return NULL;
158 + }
159 st = nst;
160 }
161