Fix a long-standing memory leak in account prefs.
authorAndrej Kacian <ticho@claws-mail.org>
Sun, 9 Jul 2017 16:27:20 +0000 (18:27 +0200)
committerAndrej Kacian <ticho@claws-mail.org>
Sun, 9 Jul 2017 16:27:20 +0000 (18:27 +0200)
commit8c3760e3461510a1889195d2d027ebd4db6ca5bd
treed796b6cef64754d1fdd2e0bb417ec26b7f68bb2c
parent99f705739502ca022401a95b776855eff551ce94
Fix a long-standing memory leak in account prefs.

All P_STRING type prefs with non-NULL default values
were being leaked due to overly complicated account
config loading, where we would first initialize
a fresh PrefAccount, then load prefs from config, copying
data between the static tmp_ac_prefs and our dynamically
allocated PrefAccount several times.

Instead of adding another round of data copying from/to
tmp_ac_prefs for purpose of free()ing the P_STRING prefs,
this commit changes prefs_account_read_config() into
prefs_account_new_from_config(), a
Existing accounts are now created with simple:
  ac_prefs = prefs_account_new_from_config(...);
instead of previous:
  ac_prefs = prefs_account_new();
  prefs_account_read_from_config(ac_prefs, ...);

The new function sets up contents of tmp_ac_prefs,
and then its contents are only copied to the newly
allocated PrefsAccount once.
src/account.c
src/prefs_account.c
src/prefs_account.h