summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorKirill Volinsky <mataes2007@gmail.com>2015-05-14 19:59:18 +0000
committerKirill Volinsky <mataes2007@gmail.com>2015-05-14 19:59:18 +0000
commit6b0510d035977680aedde109cbdae0cf4c8f44c9 (patch)
tree112296cf10ea3a56d188c2a5096c7bff968419f1 /plugins
parent0225e25a20995f5b091c31ea1ea91306bfc8e23c (diff)
memory corruption fix
git-svn-id: http://svn.miranda-ng.org/main/trunk@13596 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins')
-rw-r--r--plugins/FavContacts/src/http_api.cpp34
1 files changed, 18 insertions, 16 deletions
diff --git a/plugins/FavContacts/src/http_api.cpp b/plugins/FavContacts/src/http_api.cpp
index a201c6cbda..77f918a1c9 100644
--- a/plugins/FavContacts/src/http_api.cpp
+++ b/plugins/FavContacts/src/http_api.cpp
@@ -6,7 +6,7 @@
#define MS_FAVCONTACTS_OPEN_CONTACT "FavContacts/OpenContact"
-class CHttpProcessor: public IConnectionProcessor
+class CHttpProcessor : public IConnectionProcessor
{
private:
CSocket *m_socket;
@@ -21,26 +21,28 @@ private:
}
public:
- CHttpProcessor(CSocket *s): m_socket(s) {}
+ CHttpProcessor(CSocket *s) : m_socket(s) {}
void ProcessConnection()
{
char buf[1024];
int n = m_socket->Recv(buf, sizeof(buf));
- buf[n] = 0;
+ if (n > 0) {
+ buf[n] = 0;
- char *s = FetchURL(buf);
+ char *s = FetchURL(buf);
- if (!strncmp(s, "/fav/list/", 10))
- {
- SendList();
- } else
- if (!strncmp(s, "/fav/open/", 10))
- {
- OpenContact(s);
- }
+ if (!strncmp(s, "/fav/list/", 10))
+ {
+ SendList();
+ }
+ else if (!strncmp(s, "/fav/open/", 10))
+ {
+ OpenContact(s);
+ }
- mir_free(s);
+ mir_free(s);
+ }
m_socket->Close();
}
@@ -117,7 +119,7 @@ public:
{
int length = 0;
const XCHAR *p;
- for (p = s; *p; p++)
+ for (p = s; *p; p++)
{
if (*p == '\'' || *p == '\\' || *p == '\"')
length++;
@@ -125,7 +127,7 @@ public:
}
XCHAR *buf = (XCHAR *)mir_alloc(sizeof(XCHAR) * (length + 1));
XCHAR *q = buf;
- for (p = s; *p; p++)
+ for (p = s; *p; p++)
{
if (*p == '\'' || *p == '\\' || *p == '\"')
{
@@ -141,7 +143,7 @@ public:
}
};
-class CHttpProcessorFactory: public IConnectionProcessorFactory
+class CHttpProcessorFactory : public IConnectionProcessorFactory
{
public:
IConnectionProcessor *Create(CSocket *s)