Closed jaraco closed 8 years ago
Original comment by Jason R. Coombs (Bitbucket: jaraco, GitHub: jaraco):
I should point out that .contents
simply de-references a pointer, so struct_p.contents
in Python (when using ctypes) is equivalent to *struct_p
in C.
At the point where struct_p.contents
is referenced, struct_p
is known to be non-null (because of the while struct_p
test immediately before). It's conceivable that struct_p.contents.next
may be null, but that's fine, because it's subsequently tested by while struct_p
.
I don't see an issue here. Can you provide more detail on how you triggered the failure?
Originally reported by: Jason R. Coombs (Bitbucket: jaraco, GitHub: jaraco)
Mark Woan reports:
Whilst calling the GetAdaptersAddresses method (inet.py) I found that it would give a null pointer exception when it attempted to enumerate a non-existant network adapter as the struct_p variable always appears to be valid.
I have only just moved over to python from C# so I am not sure my fix is optimal! In the end I changed the loop like so:
Below is a screenshot from Visual Studio showing the contents of struct_p