summaryrefslogtreecommitdiff
path: root/streaming.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-02-19 00:00:53 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-02-19 00:00:53 (GMT)
commit78368f2c1ad342719ccf1e719bd5126ca6c7b68b (patch)
tree7fbeaf3abefa9c7ecf66770309c5617b8f146667 /streaming.c
parentd954828d45efbd4b53576e86066657e87391318d (diff)
downloadgit-78368f2c1ad342719ccf1e719bd5126ca6c7b68b.zip
git-78368f2c1ad342719ccf1e719bd5126ca6c7b68b.tar.gz
git-78368f2c1ad342719ccf1e719bd5126ca6c7b68b.tar.bz2
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>
Diffstat (limited to 'streaming.c')
-rw-r--r--streaming.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/streaming.c b/streaming.c
index d7c9f32..2ff036a 100644
--- a/streaming.c
+++ b/streaming.c
@@ -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;
}