Menu

#50 Fix printing of empty string pointers

v1.0 (example)
closed-fixed
nobody
None
5
2016-03-19
2015-10-26
No

Fix printing of empty string pointers

Once the check if str is NULL is reached, str has already been
derereferenced in the for loop, so in the case that the if clause would
be entered, the program has already crashed due to a null pointer
dereference.

By checking the content of str before dereferencing, the code in the if
clause is actually useful.

for (ptr=str;ptr;ptr++) flag|=((ptr>0 && ptr<32)||(ptr=='\"')||(*ptr=='\'))?1:0;

...

if (!str)
...

1 Attachments

Discussion

  • Dave Gamble

    Dave Gamble - 2016-03-19

    Merged upstream, again with thanks :)

     
  • Dave Gamble

    Dave Gamble - 2016-03-19
    • status: unread --> closed-fixed
     

Log in to post a comment.