Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

instance variable access (via self) results in a null pointer dereference

Running an analysis on my app results in the logical error in the subject. I don't really know what that means. Below is a screen of the error:

enter image description here

like image 583
Diferdin Avatar asked Apr 20 '12 13:04

Diferdin


People also ask

What happens if I dereference a NULL pointer?

Dereferencing a null pointer always results in undefined behavior and can cause crashes. If the compiler finds a pointer dereference, it treats that pointer as nonnull. As a result, the optimizer may remove null equality checks for dereferenced pointers.

What does dereferencing a null pointer mean?

A NULL pointer dereference occurs when the application dereferences a pointer that it expects to be valid, but is NULL, typically causing a crash or exit. Extended Description. NULL pointer dereference issues can occur through a number of flaws, including race conditions, and simple programming omissions.

How do I know if a pointer is pointing to null?

Test whether the variable is true. A simple if (ptr) tests whether ptr is TRUE. It will return FALSE if ptr is NULL, or if ptr is 0.

What is null pointer vulnerability?

ABSTRACT Null pointer dereference (NPD) is a widespread vulnerability that occurs whenever an executing program attempts to dereference a null pointer. NPD vulnerability can be exploited by hackers to maliciously crash a process to cause a denial of service or execute an arbitrary code under specific conditions.


1 Answers

The path it's showing you is super returning nil. If this happens, you continue to execute the method; the implicit self deference is because isShowingLandscapeView is an instance variable. You need to put all your initialisation inside the if (self) block to avoid this.

like image 79
Adam Wright Avatar answered Sep 30 '22 20:09

Adam Wright