[yelp] Swap the if() checks to avoid possible null pointer dereference



commit cbf737eaa23f22fb73b439a2c76a0e18080d7a87
Author: Tomas Popela <tpopela redhat com>
Date:   Mon Jul 23 11:53:13 2018 +0200

    Swap the if() checks to avoid possible null pointer dereference
    
    yelp-3.28.1/libyelp/yelp-transform.c:501: deref_ptr: Directly dereferencing pointer "ctxt".
    yelp-3.28.1/libyelp/yelp-transform.c:504: check_after_deref: Null-checking "ctxt" suggests that it may be 
null, but it has already been dereferenced on all paths leading to the check.

 libyelp/yelp-transform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/libyelp/yelp-transform.c b/libyelp/yelp-transform.c
index 7a5dc86e..0a1c8058 100644
--- a/libyelp/yelp-transform.c
+++ b/libyelp/yelp-transform.c
@@ -498,10 +498,10 @@ xslt_yelp_document (xsltTransformContextPtr ctxt,
 
     debug_print (DB_FUNCTION, "entering\n");
 
-    if (ctxt->state == XSLT_STATE_STOPPED)
+    if (!ctxt || !node || !inst || !comp)
         return;
 
-    if (!ctxt || !node || !inst || !comp)
+    if (ctxt->state == XSLT_STATE_STOPPED)
         return;
 
     transform = YELP_TRANSFORM (ctxt->_private);


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