summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2014-12-20 19:10:44 +0000
committerRobert Pösel <robyer@seznam.cz>2014-12-20 19:10:44 +0000
commit9f98d623506e7b7a86561152807526aeb2bb5be3 (patch)
tree271ff3535fa7cc8d2d74f82aebe179312c69aa9a /protocols
parentc913257a1eb9b0fdcac33c1b45b309261048f761 (diff)
Omegle: Various code improvements (as reported by Coverity analyser); version bump
This also fixes no locking of EventsLoop (and eventually related issues) git-svn-id: http://svn.miranda-ng.org/main/trunk@11545 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/Omegle/src/client.h4
-rw-r--r--protocols/Omegle/src/communication.cpp7
-rw-r--r--protocols/Omegle/src/messages.cpp13
-rw-r--r--protocols/Omegle/src/proto.cpp1
-rw-r--r--protocols/Omegle/src/version.h2
5 files changed, 16 insertions, 11 deletions
diff --git a/protocols/Omegle/src/client.h b/protocols/Omegle/src/client.h
index 8506c14556..cc7894b382 100644
--- a/protocols/Omegle/src/client.h
+++ b/protocols/Omegle/src/client.h
@@ -44,6 +44,10 @@ public:
old_typing_ = typing_ = spy_mode_ = false;
+ error_count_ = 0;
+
+ parent = NULL;
+ handle_ = NULL;
hConnection = NULL;
hEventsConnection = NULL;
connection_lock_ = NULL;
diff --git a/protocols/Omegle/src/communication.cpp b/protocols/Omegle/src/communication.cpp
index fb2641a88b..eba4f12aca 100644
--- a/protocols/Omegle/src/communication.cpp
+++ b/protocols/Omegle/src/communication.cpp
@@ -136,10 +136,10 @@ bool Omegle_client::handle_error(const std::string &method, bool force_disconnec
std::string Omegle_client::get_server( bool not_last )
{
- BYTE q = not_last ? 1 : 0;
+ int q = not_last ? 1 : 0;
int server = db_get_b(NULL, parent->m_szModuleName, OMEGLE_KEY_SERVER, 0);
- if (server < 0 || server >= (SIZEOF(servers)-q))
+ if (server < 0 || server >= (int)(SIZEOF(servers)-q))
server = 0;
if (server == 0) {
@@ -286,6 +286,7 @@ NETLIBHTTPHEADER* Omegle_client::get_request_headers( int request_type, int* hea
case OMEGLE_REQUEST_RECAPTCHA:
headers[3].szName = "Content-Type";
headers[3].szValue = "application/x-www-form-urlencoded; charset=utf-8";
+ // intentionally no break;
case OMEGLE_REQUEST_HOME:
case OMEGLE_REQUEST_COUNT:
@@ -304,7 +305,7 @@ NETLIBHTTPHEADER* Omegle_client::get_request_headers( int request_type, int* hea
void Omegle_client::store_headers( http::response* resp, NETLIBHTTPHEADER* headers, int headersCount )
{
- for ( size_t i = 0; i < headersCount; i++ )
+ for ( size_t i = 0; i < (size_t)headersCount; i++ )
{
std::string header_name = headers[i].szName;
std::string header_value = headers[i].szValue;
diff --git a/protocols/Omegle/src/messages.cpp b/protocols/Omegle/src/messages.cpp
index e7655c421c..17647bc813 100644
--- a/protocols/Omegle/src/messages.cpp
+++ b/protocols/Omegle/src/messages.cpp
@@ -29,18 +29,17 @@ void OmegleProto::SendMsgWorker(void *p)
ScopedLock s( facy.send_message_lock_ );
- std::string *data = static_cast<std::string*>(p);
+ std::string data = *(std::string*)p;
+ delete (std::string*)p;
- *data = utils::text::trim(*data);
+ data = utils::text::trim(data);
- if (facy.state_ == STATE_ACTIVE && data->length() && facy.send_message( *data ))
+ if (facy.state_ == STATE_ACTIVE && data.length() && facy.send_message( data ))
{
- TCHAR *msg = mir_a2t_cp(data->c_str(), CP_UTF8);
+ TCHAR *msg = mir_a2t_cp(data.c_str(), CP_UTF8);
UpdateChat(facy.nick_, msg);
mir_free(msg);
}
-
- delete data;
}
void OmegleProto::SendTypingWorker(void *p)
@@ -50,7 +49,7 @@ void OmegleProto::SendTypingWorker(void *p)
// Save typing info
bool typ = (*static_cast<int*>(p) == PROTOTYPE_SELFTYPING_ON);
- delete p;
+ delete (int*)p;
// Ignore same typing info
if (facy.typing_ == typ)
diff --git a/protocols/Omegle/src/proto.cpp b/protocols/Omegle/src/proto.cpp
index bc785a9c44..6a83523bf1 100644
--- a/protocols/Omegle/src/proto.cpp
+++ b/protocols/Omegle/src/proto.cpp
@@ -31,6 +31,7 @@ OmegleProto::OmegleProto(const char* proto_name, const TCHAR* username) :
this->log_lock_ = CreateMutex( NULL, FALSE, NULL );
this->facy.send_message_lock_ = CreateMutex( NULL, FALSE, NULL );
this->facy.connection_lock_ = CreateMutex( NULL, FALSE, NULL );
+ this->events_loop_lock_ = CreateMutex( NULL, FALSE, NULL );
// Group chats
CreateProtoService(PS_JOINCHAT, &OmegleProto::OnJoinChat);
diff --git a/protocols/Omegle/src/version.h b/protocols/Omegle/src/version.h
index 4548480467..0283d39a9a 100644
--- a/protocols/Omegle/src/version.h
+++ b/protocols/Omegle/src/version.h
@@ -1,7 +1,7 @@
#define __MAJOR_VERSION 0
#define __MINOR_VERSION 1
#define __RELEASE_NUM 2
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#include <stdver.h>