[clang] [analyzer] Avoid crashes in the stream checker (PR #100901)

Balazs Benics via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 29 01:11:17 PDT 2024


steakhal wrote:

> In the state dump I see that `stdout` seems to be NULL (last line in "constraints"). This explains why the `StateNull` becomes NULL, because call to `assumeNoAliasingWithStdStreams` was called already. I think the better solution is to check NULL-ness of the std stream variable `assumeNoAliasingWithStdStreams` and do not assume if it is NULL. There is not a case when `fopen` returns non-null for sure, but at least not in the current situation, so the current fix is not as good. We could add an `assert` to check if both `StateNull` and `StateNotNull` are non-zero.

Exactly. I didn't want to rush too much, but I can share that my current idea is to call `assumeNoAliasingWithStdStreams` only on the success path.

https://github.com/llvm/llvm-project/pull/100901


More information about the cfe-commits mailing list