https://gitlab.synchro.net/main/sbbs/-/commit/3980634758b2757f7645fb67
Modified Files:
src/smblib/smblib.c
Log Message:
smblib: smb_copymsgmem() leaves nothing allocated when it fails
On a failed malloc(), smb_copymsgmem() returned with whatever it had
already allocated for the copy still in it (leaked by callers that do not
free the copy), and with the copy's dfield, hfield and hfield_dat still pointing at the source message's arrays wherever it had not replaced
them yet. A caller that frees both after a failure, as MsgBase.copy_msg()
and move_msg() do, then freed the source's arrays twice, and one that
freed the copy after a failure part-way through the header fields freed
the uninitialized entries of hfield_dat.
The copy now starts with no arrays of its own, allocates hfield_dat
zeroed, and on any failure frees what it allocated, leaving the copy
holding no allocations, so smb_freemsgmem() on it is safe and not freeing
it leaks nothing.
Coverity CIDs 662423, 662427, 662429 (bulkmail.cpp).
Co-Authored-By: Claude Opus 5.5 <
noreply@anthropic.com>
--- SBBSecho 3.38-Linux
* Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)