jstedfast / gmime

A C/C++ MIME creation and parser library with support for S/MIME, PGP, and Unix mbox spools.
GNU Lesser General Public License v2.1
111 stars 36 forks source link

Avoid clearing a header list if it is being appended to. #130

Closed dkg closed 1 year ago

dkg commented 1 year ago

I think this resolves a copy/paste error that was introduced in 4a80ae527df9aa36fe50fac0878207a31d4d6b72.

The logic for message_add_addresses is that it is supposed to just be appending to a list of addresses, rather than trying to re-merge a series of addresses.

It looks like the function's framing was copy/pasted from message_update_addresses, which does the more complete re-build/re-merge.

However, message_update_addresses starts with an initial internet_address_list_clear, and then proceeds to cycle through the entire list of headers, trying to collect the ones that match the field name, so clearing the address list initially makes sense.

For message_add_addresses though, the goal is just to append to the current list that already exists, so the list should not be initially cleared.

Fixes: #129

dkg commented 1 year ago

thanks for the prompt review and merge, @jstedfast !

jstedfast commented 1 year ago

No prob. Thanks for debugging this and figuring out the problem :-)