From 4c814798c7bc7f6a0f92c21b027b26290622aa2f Mon Sep 17 00:00:00 2001 From: George Hazan Date: Fri, 19 Jun 2015 19:35:42 +0000 Subject: SIZEOF replaced with more secure analog - _countof git-svn-id: http://svn.miranda-ng.org/main/trunk@14270 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Omegle/src/communication.cpp | 12 ++++++------ protocols/Omegle/src/dialogs.cpp | 10 +++++----- protocols/Omegle/src/main.cpp | 2 +- protocols/Omegle/src/proto.cpp | 2 +- protocols/Omegle/src/theme.cpp | 6 +++--- protocols/Omegle/src/utils.cpp | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) (limited to 'protocols/Omegle') diff --git a/protocols/Omegle/src/communication.cpp b/protocols/Omegle/src/communication.cpp index eb7b739c75..ce0afcc440 100644 --- a/protocols/Omegle/src/communication.cpp +++ b/protocols/Omegle/src/communication.cpp @@ -162,12 +162,12 @@ std::string Omegle_client::get_server( bool not_last ) int q = not_last ? 1 : 0; int server = db_get_b(NULL, parent->m_szModuleName, OMEGLE_KEY_SERVER, 0); - if (server < 0 || server >= (int)(SIZEOF(servers)-q)) + if (server < 0 || server >= (int)(_countof(servers)-q)) server = 0; if (server == 0) { srand(::time(NULL)); - server = (rand() % (SIZEOF(servers)-1-q))+1; + server = (rand() % (_countof(servers)-1-q))+1; } return servers[server]; @@ -176,7 +176,7 @@ std::string Omegle_client::get_server( bool not_last ) std::string Omegle_client::get_language() { int language = db_get_b(NULL, parent->m_szModuleName, OMEGLE_KEY_LANGUAGE, 0); - if (language < 0 || language >= (SIZEOF(languages))) + if (language < 0 || language >= (_countof(languages))) language = 0; return language > 0 ? languages[language].id : "en"; @@ -300,7 +300,7 @@ bool Omegle_client::start() if (this->spy_mode_) { //// get last server from list, which is for spy mode - //this->server_ = servers[SIZEOF(servers)-1]; + //this->server_ = servers[_countof(servers)-1]; if (this->question_.empty()) { data = "&wantsspy=1"; @@ -551,7 +551,7 @@ bool Omegle_client::events() st.cbSize = sizeof(st); // st.hIcon = IcoLib_GetIconByHandle(GetIconHandle("typing_on")); // TODO: typing icon - mir_sntprintf(st.tszText, SIZEOF(st.tszText), TranslateT("%s is typing."), TranslateT("Stranger")); + mir_sntprintf(st.tszText, _countof(st.tszText), TranslateT("%s is typing."), TranslateT("Stranger")); CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)parent->GetChatHandle(), (LPARAM)&st); } @@ -566,7 +566,7 @@ bool Omegle_client::events() st.cbSize = sizeof(st); // st.hIcon = IcoLib_GetIconByHandle(GetIconHandle("typing_off")); // TODO: typing icon - mir_sntprintf(st.tszText, SIZEOF(st.tszText), TranslateT("%s stopped typing."), TranslateT("Stranger")); + mir_sntprintf(st.tszText, _countof(st.tszText), TranslateT("%s stopped typing."), TranslateT("Stranger")); CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)parent->GetChatHandle(), (LPARAM)&st); } diff --git a/protocols/Omegle/src/dialogs.cpp b/protocols/Omegle/src/dialogs.cpp index c2f13d2995..7d5754e8a3 100644 --- a/protocols/Omegle/src/dialogs.cpp +++ b/protocols/Omegle/src/dialogs.cpp @@ -47,7 +47,7 @@ static void StoreDBText(OmegleProto* ppro, HWND hwnd, int idCtrl, const char* sz { TCHAR tstr[250+1]; - GetDlgItemText(hwnd, idCtrl, tstr, SIZEOF(tstr)); + GetDlgItemText(hwnd, idCtrl, tstr, _countof(tstr)); if (tstr[0] != '\0') { db_set_ts(NULL, ppro->m_szModuleName, szSetting, tstr); } else { @@ -73,12 +73,12 @@ INT_PTR CALLBACK OmegleAccountProc( HWND hwnd, UINT message, WPARAM wparam, LPAR // Server SendDlgItemMessageA(hwnd, IDC_SERVER, CB_INSERTSTRING, 0, reinterpret_cast(Translate(servers[0]))); - for(size_t i=1; i(servers[i])); SendDlgItemMessage(hwnd, IDC_SERVER, CB_SETCURSEL, db_get_b(NULL, proto->m_szModuleName, OMEGLE_KEY_SERVER, 0), 0); // Language - for(size_t i=0; i(Translate(languages[i].lang))); SendDlgItemMessage(hwnd, IDC_LANGUAGE, CB_SETCURSEL, db_get_b(NULL, proto->m_szModuleName, OMEGLE_KEY_LANGUAGE, 0), 0); @@ -150,12 +150,12 @@ INT_PTR CALLBACK OmegleOptionsProc( HWND hwnd, UINT message, WPARAM wparam, LPAR // Server SendDlgItemMessageA(hwnd, IDC_SERVER, CB_INSERTSTRING, 0, reinterpret_cast(Translate(servers[0]))); - for(size_t i=1; i(servers[i])); SendDlgItemMessage(hwnd, IDC_SERVER, CB_SETCURSEL, db_get_b(NULL, proto->m_szModuleName, OMEGLE_KEY_SERVER, 0), 0); // Language - for(size_t i=0; i(Translate(languages[i].lang))); SendDlgItemMessage(hwnd, IDC_LANGUAGE, CB_SETCURSEL, db_get_b(NULL, proto->m_szModuleName, OMEGLE_KEY_LANGUAGE, 0), 0); diff --git a/protocols/Omegle/src/main.cpp b/protocols/Omegle/src/main.cpp index fdc7d17897..be47e64da6 100644 --- a/protocols/Omegle/src/main.cpp +++ b/protocols/Omegle/src/main.cpp @@ -134,7 +134,7 @@ extern "C" int __declspec(dllexport) Load(void) extern "C" int __declspec(dllexport) Unload(void) { //UninitContactMenus(); - for(size_t i=0; i