steakhal added a comment.
Some checker should have caught the uninitialized value earlier than the
`defaultEvalCall()`.
I guess, the `MallocCkecher` could have checked for it in `PreStmt<CXXNewExpr>`.
Or alternatively, the `CallAndMessageChecker::preCall()` already does something
like this in the `PreVisitProcessArg()`. I know that `CXXNewExpr` is not a
//call//, but you get the idea.
WDYT, worth catching it?
Other than that, I think it's a good practice to not rely on some checkers to
catch things to prevent crashes; so this 'fix' seems reasonable to me.
================
Comment at: clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp:768
+ if (Size.isUndef())
+ Size = UnknownVal();
+
----------------
I'm not a fan of mutating values like this.
Alternatively we could have used something like this at the point of use:
`Size.getAs<DefinedOrUnknownSVal>().getValueOr(UnknownVal{})`
I'm not sure if it's more readable :D
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130974/new/
https://reviews.llvm.org/D130974
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits