Page MenuHomeFreeBSD

hdb_add_current_keys_to_history: pass correct `size` to calloc
Needs ReviewPublic

Authored by ngie on Tue, Feb 3, 8:20 PM.
Tags
None
Referenced Files
F144082071: D55090.diff
Wed, Feb 4, 11:17 AM
F144052823: D55090.id171107.diff
Tue, Feb 3, 11:40 PM
F144049795: D55090.id.diff
Tue, Feb 3, 10:32 PM
F144049768: D55090.id171107.diff
Tue, Feb 3, 10:31 PM
F144048178: D55090.diff
Tue, Feb 3, 9:57 PM
Subscribers

Details

Summary

The size being passed to calloc prior to this change was incorrectly
calculated. The value passed should have been the type, not a
dereferenced pointer to a scalar value that happens to be the type.

This also avoids a NULL pointer dereference, which would have resulted
in a crash.

This fixes a -Wfree-nonheap-object issue cited by gcc 14.

MFC after: 3 days
PR: 292916

Test Plan

The code compiles/links without warnings with gcc14 on :main after this change.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 70379
Build 67262: arc lint + arc unit

Event Timeline

ngie requested review of this revision.Tue, Feb 3, 8:20 PM
ngie added reviewers: rmacklem, cy.
ngie retitled this revision from hdb_add_current_keys_to_history: pass correct memory size to calloc to hdb_add_current_keys_to_history: pass correct `size` to calloc.
ngie added a subscriber: jhb.