this is null

Ali Çehreli acehreli at yahoo.com
Sat Mar 9 21:00:51 UTC 2019


On 03/09/2019 12:10 PM, ANtlord wrote:
> On Saturday, 9 March 2019 at 20:04:53 UTC, Paul Backus wrote:
>>
>> You can end up with a null `this` reference if you dereference a null 
>> pointer to a struct and then call a method on the result. For example:
>>
> 
> I can but my reference is not null before calling. Take a look at the 
> line of code [0]. There is a check before the line.
> 
> https://github.com/ANtlord/deadmemory/blob/master/src/deadmemory/mem.d#L20 
> [0]

I haven't run the code but which pointer is null? Try adding this check 
as well:

   auto node = this.list.getFisrtFreeOrAdd(memViewLen);
   assert(node !is null);

Ali


More information about the Digitalmars-d-learn mailing list