Menu

null pointer can not be checked

wy163
2024-12-31
2024-12-31
  • wy163

    wy163 - 2024-12-31

    Hi, I made a code sample, on which null pointer error or warning should be reported by cppcheck. But I can't get the expected result.

    #include <stdio.h>
    
    void main() {
        char * p = NULL;
        char ** x = NULL;
        char * s = "abc";
    
        for ( ;; ) {
    
            if(p) {
                *x = s;
            } else {
                p = s;
                printf("got p\n");
            }
        }
        printf("null point\n");
    }
    

    Could you help take a look? Thanks!

     
  • CHR

    CHR - 2024-12-31

    Thanks for reporting, ticket is here: https://trac.cppcheck.net/ticket/13503

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.