From 4fb42b711df5d8a9986d9587d7a1edc72f13eb0c Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Sun, 2 Nov 2014 11:19:25 +0000 Subject: NewsAggregator: -Fixed memory leak -Fixed crash when server isn't available -performance improvements git-svn-id: http://svn.miranda-ng.org/main/trunk@10899 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/NewsAggregator/Src/Authentication.cpp | 30 +++++++++++++-------------- 1 file changed, 14 insertions(+), 16 deletions(-) (limited to 'plugins/NewsAggregator/Src/Authentication.cpp') diff --git a/plugins/NewsAggregator/Src/Authentication.cpp b/plugins/NewsAggregator/Src/Authentication.cpp index 47918c4706..5d3a56b645 100644 --- a/plugins/NewsAggregator/Src/Authentication.cpp +++ b/plugins/NewsAggregator/Src/Authentication.cpp @@ -21,24 +21,19 @@ Boston, MA 02111-1307, USA. void CreateAuthString(char *auth, MCONTACT hContact, HWND hwndDlg) { - DBVARIANT dbv; - char *user = NULL, *pass = NULL; - TCHAR *tlogin = NULL, *tpass = NULL, buf[MAX_PATH] = {0}; + TCHAR *tlogin = NULL, *tpass = NULL; if (hContact && db_get_b(hContact, MODULE, "UseAuth", 0)) { - if (!db_get_ts(hContact, MODULE, "Login", &dbv)) { - tlogin = mir_tstrdup(dbv.ptszVal); - db_free(&dbv); - } + tlogin = db_get_tsa(hContact, MODULE, "Login"); tpass = db_get_tsa(hContact, MODULE, "Password"); } else if (hwndDlg && IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)) { + TCHAR buf[MAX_PATH] = {0}; GetDlgItemText(hwndDlg, IDC_LOGIN, buf, SIZEOF(buf)); tlogin = mir_tstrdup(buf); GetDlgItemText(hwndDlg, IDC_PASSWORD, buf, SIZEOF(buf)); tpass = mir_tstrdup(buf); } - user = mir_t2a(tlogin); - pass = mir_t2a(tpass); + char *user = mir_t2a(tlogin), *pass = mir_t2a(tpass); char str[MAX_PATH]; int len = mir_snprintf(str, SIZEOF(str), "%s:%s", user, pass); @@ -69,14 +64,17 @@ INT_PTR CALLBACK AuthenticationProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARA } } else if (SelItem.hContact) { - DBVARIANT dbv; - if (!db_get_ts(SelItem.hContact, MODULE, "Nick", &dbv)) { - SetDlgItemText(hwndDlg, IDC_FEEDNAME, dbv.ptszVal); - db_free(&dbv); + TCHAR *ptszNick = db_get_tsa(SelItem.hContact, MODULE, "Nick"); + if (ptszNick) { + SetDlgItemText(hwndDlg, IDC_FEEDNAME, ptszNick); + mir_free(ptszNick); } - else if (!db_get_ts(SelItem.hContact, MODULE, "URL", &dbv)) { - SetDlgItemText(hwndDlg, IDC_FEEDNAME, dbv.ptszVal); - db_free(&dbv); + else { + TCHAR *ptszURL = db_get_tsa(SelItem.hContact, MODULE, "URL"); + if (ptszURL) { + SetDlgItemText(hwndDlg, IDC_FEEDNAME, ptszURL); + mir_free(ptszURL); + } } } } -- cgit v1.2.3