HomeFreeBSD

scandir: Fix NULL dereference, uninitialized value use in error case

Description

scandir: Fix NULL dereference, uninitialized value use in error case

If opendir succeeds but malloc fails, numitems was used uninitialized in
error handling under the 'fail' label. If it happened to have a non-zero
value, the NULL 'names' was dereferenced.

Reported by: Coverity
CIDs: 1329566, 1372625
Sponsored by: Dell EMC Isilon

Details

Provenance
cemAuthored on
Parents
rS315719: Extend cmpxchg() to support 8- and 16-bit values, and add xchg().
Branches
Unknown
Tags
Unknown