[evolution-data-server] [NNTP] Address REVERSE_INULL Coverity scan issue



commit 1cf4b38b37cbe1671eb81fc780d7102e23110d8d
Author: Milan Crha <mcrha redhat com>
Date:   Mon Sep 3 17:09:54 2018 +0200

    [NNTP] Address REVERSE_INULL Coverity scan issue
    
    src/camel/providers/nntp/camel-nntp-store.c:2252: deref_ptr: Directly dereferencing pointer "nntp_stream"
    src/camel/providers/nntp/camel-nntp-store.c:2355: check_after_deref: Null-checking "nntp_stream" suggests 
that it may be null, but it has already been dereferenced on all paths leading to the check.
      2353|
      2354|                 if (ret == -1) {
      2355|->                       if (nntp_stream)
      2356|                                 camel_nntp_stream_unlock (nntp_stream);
      2357|

 src/camel/providers/nntp/camel-nntp-store.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
---
diff --git a/src/camel/providers/nntp/camel-nntp-store.c b/src/camel/providers/nntp/camel-nntp-store.c
index 6e99d892b..9c4dd55e4 100644
--- a/src/camel/providers/nntp/camel-nntp-store.c
+++ b/src/camel/providers/nntp/camel-nntp-store.c
@@ -2243,7 +2243,14 @@ camel_nntp_command (CamelNNTPStore *nntp_store,
                        /* If we successfully connected then
                         * we should obtain a CamelNNTPStream. */
                        nntp_stream = camel_nntp_store_ref_stream (nntp_store);
-                       g_return_val_if_fail (nntp_stream != NULL, -1);
+                       if (!nntp_stream) {
+                               g_set_error (
+                                       error, CAMEL_SERVICE_ERROR,
+                                       CAMEL_SERVICE_ERROR_NOT_CONNECTED,
+                                       _("Not connected."));
+                               ret = -1;
+                               goto exit;
+                       }
                }
 
                camel_nntp_stream_lock (nntp_stream);
@@ -2352,9 +2359,7 @@ camel_nntp_command (CamelNNTPStore *nntp_store,
                }
 
                if (ret == -1) {
-                       if (nntp_stream)
-                               camel_nntp_stream_unlock (nntp_stream);
-
+                       camel_nntp_stream_unlock (nntp_stream);
                        g_clear_object (&nntp_stream);
                }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]