diff options
author | George Hazan <george.hazan@gmail.com> | 2015-04-10 14:25:42 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-04-10 14:25:42 +0000 |
commit | 77a9ce1c7510cdf66bf038300ce57952748a3e05 (patch) | |
tree | ee1689e603b83f7f359c6098be2881e0c5b707c0 /src | |
parent | 11c3c76e22bb5778da1f14041fd6bac50d2cc747 (diff) |
- fix for CREOleCallback constructor;
- unsafe strlen call removed;
- fix for static buffer lengths
git-svn-id: http://svn.miranda-ng.org/main/trunk@12736 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'src')
-rw-r--r-- | src/core/stdchat/src/chat.h | 2 | ||||
-rw-r--r-- | src/core/stdchat/src/main.cpp | 12 | ||||
-rw-r--r-- | src/core/stdmsg/src/msglog.cpp | 2 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgoptions.cpp | 25 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.cpp | 12 | ||||
-rw-r--r-- | src/core/stdmsg/src/msgs.h | 2 |
6 files changed, 28 insertions, 27 deletions
diff --git a/src/core/stdchat/src/chat.h b/src/core/stdchat/src/chat.h index 97c5496fd1..6212eb7c73 100644 --- a/src/core/stdchat/src/chat.h +++ b/src/core/stdchat/src/chat.h @@ -113,7 +113,7 @@ extern BOOL SmileyAddInstalled, PopupInstalled; struct CREOleCallback : public IRichEditOleCallback
{
- CREOleCallback() : refCount(0) {}
+ CREOleCallback() : refCount(0), nextStgId(0), pictStg(NULL) {}
unsigned refCount;
IStorage *pictStg;
int nextStgId;
diff --git a/src/core/stdchat/src/main.cpp b/src/core/stdchat/src/main.cpp index 9437b3a034..48b31036a2 100644 --- a/src/core/stdchat/src/main.cpp +++ b/src/core/stdchat/src/main.cpp @@ -420,19 +420,19 @@ STDMETHODIMP CREOleCallback::QueryInterface(REFIID riid, LPVOID * ppvObj) STDMETHODIMP_(ULONG) CREOleCallback::AddRef()
{
- if (refCount == 0) {
- if (S_OK != StgCreateDocfile(NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_DELETEONRELEASE, 0, &pictStg))
- pictStg = NULL;
- nextStgId = 0;
- }
+ if (refCount == 0)
+ StgCreateDocfile(NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_DELETEONRELEASE, 0, &pictStg);
+
return ++refCount;
}
STDMETHODIMP_(ULONG) CREOleCallback::Release()
{
if (--refCount == 0) {
- if (pictStg)
+ if (pictStg) {
pictStg->Release();
+ pictStg = NULL;
+ }
}
return refCount;
}
diff --git a/src/core/stdmsg/src/msglog.cpp b/src/core/stdmsg/src/msglog.cpp index c25f1bdd2d..9a458701f0 100644 --- a/src/core/stdmsg/src/msglog.cpp +++ b/src/core/stdmsg/src/msglog.cpp @@ -432,7 +432,7 @@ static DWORD CALLBACK LogStreamInEvents(DWORD_PTR dwCookie, LPBYTE pbBuff, LONG *pcb = 0;
return 0;
}
- dat->bufferLen = (int)strlen(dat->buffer);
+ dat->bufferLen = (int)mir_strlen(dat->buffer);
}
*pcb = min(cb, dat->bufferLen - dat->bufferOffset);
memcpy(pbBuff, dat->buffer + dat->bufferOffset, *pcb);
diff --git a/src/core/stdmsg/src/msgoptions.cpp b/src/core/stdmsg/src/msgoptions.cpp index 8582886b1d..74788bd360 100644 --- a/src/core/stdmsg/src/msgoptions.cpp +++ b/src/core/stdmsg/src/msgoptions.cpp @@ -100,11 +100,11 @@ void RegisterSRMMFonts(void) FontIDT fontid = { sizeof(fontid) };
fontid.flags = FIDF_ALLOWREREGISTER | FIDF_DEFAULTVALID;
for (int i = 0; i < SIZEOF(fontOptionsList); i++) {
- strcpy(fontid.dbSettingsGroup, SRMMMOD);
- _tcscpy(fontid.group, LPGENT("Message log"));
- _tcscpy(fontid.name, fontOptionsList[i].szDescr);
+ strncpy_s(fontid.dbSettingsGroup, SRMMMOD, _TRUNCATE);
+ _tcsncpy_s(fontid.group, LPGENT("Message log"), _TRUNCATE);
+ _tcsncpy_s(fontid.name, fontOptionsList[i].szDescr, _TRUNCATE);
mir_snprintf(idstr, SIZEOF(idstr), "SRMFont%d", i);
- strcpy(fontid.prefix, idstr);
+ strncpy_s(fontid.prefix, idstr, _TRUNCATE);
fontid.order = i;
fontid.flags &= ~FIDF_CLASSMASK;
@@ -113,19 +113,19 @@ void RegisterSRMMFonts(void) fontid.deffontsettings.colour = fontOptionsList[i].defColour;
fontid.deffontsettings.size = fontOptionsList[i].defSize;
fontid.deffontsettings.style = fontOptionsList[i].defStyle;
- _tcscpy(fontid.deffontsettings.szFace, fontOptionsList[i].szDefFace);
+ _tcsncpy_s(fontid.deffontsettings.szFace, fontOptionsList[i].szDefFace, _TRUNCATE);
fontid.deffontsettings.charset = MsgDlgGetFontDefaultCharset(fontOptionsList[i].szDefFace);
- _tcsncpy(fontid.backgroundGroup, LPGENT("Message log"),SIZEOF(fontid.backgroundGroup));
- _tcsncpy(fontid.backgroundName, LPGENT("Background"),SIZEOF(fontid.backgroundName));
+ _tcsncpy_s(fontid.backgroundGroup, LPGENT("Message log"), _TRUNCATE);
+ _tcsncpy_s(fontid.backgroundName, LPGENT("Background"), _TRUNCATE);
FontRegisterT(&fontid);
}
ColourIDT colourid = { sizeof(colourid) };
- strcpy(colourid.dbSettingsGroup, SRMMMOD);
- strcpy(colourid.setting, SRMSGSET_BKGCOLOUR);
+ strncpy_s(colourid.dbSettingsGroup, SRMMMOD, _TRUNCATE);
+ strncpy_s(colourid.setting, SRMSGSET_BKGCOLOUR, _TRUNCATE);
colourid.defcolour = SRMSGDEFSET_BKGCOLOUR;
- _tcscpy(colourid.name, LPGENT("Background"));
- _tcscpy(colourid.group, LPGENT("Message log"));
+ _tcsncpy_s(colourid.name, LPGENT("Background"), _TRUNCATE);
+ _tcsncpy_s(colourid.group, LPGENT("Message log"), _TRUNCATE);
ColourRegisterT(&colourid);
}
@@ -135,7 +135,8 @@ struct CheckBoxValues_t {
DWORD style;
TCHAR* szDescr;
-} statusValues[] =
+}
+statusValues[] =
{
{ MODEF_OFFLINE, LPGENT("Offline") },
{ PF2_ONLINE, LPGENT("Online") },
diff --git a/src/core/stdmsg/src/msgs.cpp b/src/core/stdmsg/src/msgs.cpp index 0f3e5e5eb2..6125fbe902 100644 --- a/src/core/stdmsg/src/msgs.cpp +++ b/src/core/stdmsg/src/msgs.cpp @@ -465,19 +465,19 @@ STDMETHODIMP CREOleCallback::QueryInterface(REFIID riid, LPVOID * ppvObj) STDMETHODIMP_(ULONG) CREOleCallback::AddRef()
{
- if (refCount == 0) {
- if (S_OK != StgCreateDocfile(NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_DELETEONRELEASE, 0, &pictStg))
- pictStg = NULL;
- nextStgId = 0;
- }
+ if (refCount == 0)
+ StgCreateDocfile(NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_DELETEONRELEASE, 0, &pictStg);
+
return ++refCount;
}
STDMETHODIMP_(ULONG) CREOleCallback::Release()
{
if (--refCount == 0) {
- if (pictStg)
+ if (pictStg) {
pictStg->Release();
+ pictStg = NULL;
+ }
}
return refCount;
}
diff --git a/src/core/stdmsg/src/msgs.h b/src/core/stdmsg/src/msgs.h index 45d040d7dc..e59175c0d2 100644 --- a/src/core/stdmsg/src/msgs.h +++ b/src/core/stdmsg/src/msgs.h @@ -99,7 +99,7 @@ struct SrmmWindowData : public MZeroedObject struct CREOleCallback : public IRichEditOleCallback
{
- CREOleCallback() : refCount(0) {}
+ CREOleCallback() : refCount(0), nextStgId(0), pictStg(NULL) {}
unsigned refCount;
IStorage *pictStg;
int nextStgId;
|