diff options
author | George Hazan <george.hazan@gmail.com> | 2014-01-12 17:23:52 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-01-12 17:23:52 +0000 |
commit | 65e75cb7441999a09165e24d704702c42a9a2cd4 (patch) | |
tree | ca379ba2c7b629d812bd5237f9a09429387271df | |
parent | f7c71fc51a21f0a5956b49538510d919c1a87f67 (diff) |
crash fix for NewsAggregator
git-svn-id: http://svn.miranda-ng.org/main/trunk@7620 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | plugins/NewsAggregator/Src/Utils.cpp | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/plugins/NewsAggregator/Src/Utils.cpp b/plugins/NewsAggregator/Src/Utils.cpp index a47e6d261f..ff794bd369 100644 --- a/plugins/NewsAggregator/Src/Utils.cpp +++ b/plugins/NewsAggregator/Src/Utils.cpp @@ -73,11 +73,9 @@ VOID GetNewsData(TCHAR *tszUrl, char **szData, HANDLE hContact, HWND hwndDlg) nlhr.nlc = hNetlibHttp;
// change the header so the plugin is pretended to be IE 6 + WinXP
- if (db_get_b(hContact, MODULE, "UseAuth", 0) || IsDlgButtonChecked(hwndDlg, IDC_USEAUTH))
- nlhr.headersCount = 5;
- else
- nlhr.headersCount = 4;
- nlhr.headers = (NETLIBHTTPHEADER *)mir_alloc(sizeof(NETLIBHTTPHEADER) * nlhr.headersCount);
+ NETLIBHTTPHEADER headers[5];
+ nlhr.headersCount = 4;
+ nlhr.headers = headers;
nlhr.headers[0].szName = "User-Agent";
nlhr.headers[0].szValue = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
nlhr.headers[1].szName = "Cache-Control";
@@ -87,6 +85,7 @@ VOID GetNewsData(TCHAR *tszUrl, char **szData, HANDLE hContact, HWND hwndDlg) nlhr.headers[3].szName = "Connection";
nlhr.headers[3].szValue = "close";
if (db_get_b(hContact, MODULE, "UseAuth", 0) || IsDlgButtonChecked(hwndDlg, IDC_USEAUTH)) {
+ nlhr.headersCount++;
nlhr.headers[4].szName = "Authorization";
char auth[256];
@@ -104,31 +103,26 @@ VOID GetNewsData(TCHAR *tszUrl, char **szData, HANDLE hContact, HWND hwndDlg) memcpy(*szData, nlhrReply->pData, nlhrReply->dataLength);
(*szData)[nlhrReply->dataLength] = 0;
}
- else if (nlhrReply->resultCode == 401)
- {
+ else if (nlhrReply->resultCode == 401) {
ItemInfo SelItem = {0};
SelItem.hwndList = hwndDlg;
SelItem.hContact = hContact;
if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_AUTHENTICATION), hwndDlg, AuthenticationProc, (LPARAM)&SelItem) == IDOK)
- {
GetNewsData(tszUrl, szData, hContact, hwndDlg);
- }
}
CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)nlhrReply);
- } else {
+ }
+ else {
if (nlhr.resultCode == 401) {
ItemInfo SelItem = {0};
SelItem.hwndList = hwndDlg;
SelItem.hContact = hContact;
if (DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_AUTHENTICATION), hwndDlg, AuthenticationProc, (LPARAM)&SelItem) == IDOK)
- {
GetNewsData(tszUrl, szData, hContact, hwndDlg);
- }
}
}
mir_free(szUrl);
- mir_free(nlhr.headers);
}
VOID CreateList(HWND hwndList)
@@ -402,8 +396,9 @@ BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal) nlhr.flags = NLHRF_DUMPASTEXT | NLHRF_HTTP11;
char *szUrl = mir_t2a(tszURL);
nlhr.szUrl = szUrl;
+ NETLIBHTTPHEADER headers[4];
nlhr.headersCount = 4;
- nlhr.headers=(NETLIBHTTPHEADER *)mir_alloc(sizeof(NETLIBHTTPHEADER) * nlhr.headersCount);
+ nlhr.headers = headers;
nlhr.headers[0].szName = "User-Agent";
nlhr.headers[0].szValue = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
nlhr.headers[1].szName = "Connection";
@@ -463,7 +458,6 @@ BOOL DownloadFile(LPCTSTR tszURL, LPCTSTR tszLocal) }
mir_free(szUrl);
- mir_free(nlhr.headers);
if (hFile)
CloseHandle(hFile);
|