Possible null pointer dereference

Bug #812517 reported by Reijo Tomperi
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Inkscape
Confirmed
Undecided
Jon A. Cruz

Bug Description

These errors follow following routine:
a->foo();
if( a ){ ... }

So first pointer is used, and only after that it is checked whether it is null or not. Sometimes the check is redundant and sometimes the usage should just be guarded with the null check.

# Looks like the for-clause needs to be protected with "if(cur)". The check inside for-clause is not enough as first statement gets executed before if(cur) is checked.
[../inkscape/inkscape/src/libcroco/cr-declaration.c:759]: (error) Possible null pointer dereference: cur - otherwise it is redundant to check if cur is null at line 753

# Same as above
[../inkscape/inkscape/src/libcroco/cr-selector.c:259]: (error) Possible null pointer dereference: cur - otherwise it is redundant to check if cur is null at line 253

# Not sure if g_string_new can return null, but the check is redundant at that point for sure. If it returns null, the app will crash long before it gets that far.
[../inkscape/inkscape/src/libcroco/cr-statement.c:636]: (error) Possible null pointer dereference: stringue - otherwise it is redundant to check if stringue is null at line 638

# Classic check after using it
[../inkscape/inkscape/src/livarot/AVL.cpp:351]: (error) Possible null pointer dereference: a - otherwise it is redundant to check if a is null at line 353
[../inkscape/inkscape/src/livarot/AVL.cpp:352]: (error) Possible null pointer dereference: a - otherwise it is redundant to check if a is null at line 353

# Confirmed (some duplicate code here perhaps?)
[../inkscape/inkscape/src/livarot/AVL.cpp:410]: (error) Possible null pointer dereference: e - otherwise it is redundant to check if e is null at line 436
[../inkscape/inkscape/src/livarot/AVL.cpp:510]: (error) Possible null pointer dereference: a - otherwise it is redundant to check if a is null at line 512
[../inkscape/inkscape/src/livarot/AVL.cpp:511]: (error) Possible null pointer dereference: a - otherwise it is redundant to check if a is null at line 512
[../inkscape/inkscape/src/livarot/AVL.cpp:569]: (error) Possible null pointer dereference: e - otherwise it is redundant to check if e is null at line 595

Tags: cppcheck
su_v (suv-lp)
Changed in inkscape:
assignee: nobody → Jon A. Cruz (jon-joncruz)
status: New → Confirmed
Kris (kris-degussem)
description: updated
Kris (kris-degussem)
description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.