]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: [io]_stream_unref(NULL) should be a no-op
authorJosef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
Tue, 19 Sep 2017 10:09:07 +0000 (13:09 +0300)
committerJosef 'Jeff' Sipek <jeff.sipek@dovecot.fi>
Wed, 20 Sep 2017 09:29:06 +0000 (12:29 +0300)
src/lib/istream.c
src/lib/ostream.c

index cf5f81a382153b69f12b8cb65b3ff812b4f6a2ce..ffcf7b640e10babefab05408c544fc6f6aefc5e3 100644 (file)
@@ -49,7 +49,12 @@ void i_stream_ref(struct istream *stream)
 
 void i_stream_unref(struct istream **stream)
 {
-       struct istream_private *_stream = (*stream)->real_stream;
+       struct istream_private *_stream;
+
+       if (*stream == NULL)
+               return;
+
+       _stream = (*stream)->real_stream;
 
        if (_stream->iostream.refcount == 1) {
                if (_stream->line_str != NULL)
index 175e417b04ec6041807ee5132d436567b84477a0..abae3b07125ccfc781e1e2a0879bd796376fa2a5 100644 (file)
@@ -75,7 +75,12 @@ void o_stream_ref(struct ostream *stream)
 
 void o_stream_unref(struct ostream **_stream)
 {
-       struct ostream *stream = *_stream;
+       struct ostream *stream;
+
+       if (*_stream == NULL)
+               return;
+
+       stream = *_stream;
 
        if (stream->real_stream->last_errors_not_checked &&
            !stream->real_stream->error_handling_disabled &&