{"id":785,"date":"2020-01-10T14:38:59","date_gmt":"2020-01-10T14:38:59","guid":{"rendered":"https:\/\/sdf-docs.mansystems.com\/docs\/acr-rules\/reliability\/short-circuit-logic-should-be-used-to-prevent-null-pointer-dereferences-in-conditionals\/"},"modified":"2020-03-20T08:44:58","modified_gmt":"2020-03-20T08:44:58","slug":"shortcircuit","status":"publish","type":"docs","link":"https:\/\/sdf-docs.clevr.com\/?docs=acr-rules\/reliability\/shortcircuit","title":{"rendered":"Short-circuit logic should be used correctly to prevent null pointer dereferences in conditionals"},"content":{"rendered":"\n<p style=\"text-align:center\">Introduced in version: 1.3 (29 Jan 2020)<\/p>\n\n\n\n<p>If short circuit logic is used it should be applied correctly. Mixing up equal with not-equal or and with or will open the possibility for dereferencing of empty variables.<\/p>\n\n\n\n<p><strong> Non-compliant examples:<\/strong><br><code> $Var = empty and isMatch($Var,'qwe')<br> $Var != empty or isMatch($Var,'qwe')<br> isMatch($Var,'qwe') and $Var = empty<br> isMatch($Var,'qwe') or $Var != empty<\/code><\/p>\n\n\n\n<p><strong>Compliant examples:<\/strong><br><code> $Var != empty and isMatch($Var,'qwe')<br> $Var = empty or isMatch($Var,'qwe')<\/code><\/p>\n","protected":false},"featured_media":0,"parent":97,"menu_order":23,"comment_status":"open","ping_status":"closed","template":"","doc_tag":[],"class_list":["post-785","docs","type-docs","status-publish","hentry"],"comment_count":0,"_links":{"self":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/785"}],"collection":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=785"}],"version-history":[{"count":4,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/785\/revisions"}],"predecessor-version":[{"id":836,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/785\/revisions\/836"}],"up":[{"embeddable":true,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/97"}],"next":[{"title":"Substring function invocation should make sense","link":"https:\/\/sdf-docs.clevr.com\/?docs=acr-rules\/reliability\/badsubstring","href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/781"}],"prev":[{"title":"Seconds token should be specified correctly in parse\/format date-time functions","link":"https:\/\/sdf-docs.clevr.com\/?docs=acr-rules\/reliability\/secondvsmillisecond","href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=\/wp\/v2\/docs\/1179"}],"wp:attachment":[{"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=785"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/sdf-docs.clevr.com\/index.php?rest_route=%2Fwp%2Fv2%2Fdoc_tag&post=785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}