Visitar URL original
cpp:Does anyone know how to write rules to find this fault case of `malloc without null check`? · Issue #4084 · github/codeql · GitHub
The Wayback Machine - https://web.archive.org/web/20260320172514/https://github.com/github/codeql/issues/4084
Skip to content

cpp:Does anyone know how to write rules to find this fault case of malloc without null check? #4084

@lietdai

Description

@lietdai

Hello, I want to find "malloc without null check" by Rule cpp/ql/src/JPL_C/LOC-3/Rule 14/CheckingReturnValues.ql

void  heap_mem = malloc(20);
//right case
if (heap_mem != NULL){
   use heap_mem 
}

//fault case
use heap_mem without null check

The CheckingReturnValues.ql cannot find this fault malloc code case,
Does anyone know how to write rules to find this fault case of malloc without null check?

Metadata

Metadata

Assignees

No one assigned

    Labels

    C++questionFurther information is requested

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions