This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] Fix Static Analyzer g_memdup false-positive
ClosedPublic

Authored by steakhal on Apr 26 2022, 12:35 AM.

Details

Summary

g_memdup() allocates and copies memory, thus we should not assume that
the returned memory region is uninitialized because it might not be the
case.

PS: It would be even better to copy the bindings to mimic the actual
content of the buffer, but this works too.

Fixes #53617

Diff Detail

Event Timeline

steakhal created this revision.Apr 26 2022, 12:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2022, 12:35 AM
steakhal requested review of this revision.Apr 26 2022, 12:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2022, 12:35 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
martong accepted this revision.Apr 26 2022, 3:44 AM

Ok. LGTM.

(Just a note: it looks kind of interesting that we support the GTK related Glib functions explicitly here. I suppose they are far less frequently used than the libc or POSIX functions. This is somewhat similar to the fact that we can check WebKit or Fuchsia related code, but at least those are separated into their own checker.)

This revision is now accepted and ready to land.Apr 26 2022, 3:44 AM
This revision was automatically updated to reflect the committed changes.