Skip to content

Commit b673264

Browse files
committed
Merge pull request #20 from fiendish/master
random finds from static code analysis
2 parents 8c0f2ef + f425baa commit b673264

File tree

8 files changed

+22
-23
lines changed

8 files changed

+22
-23
lines changed

Dmetaph.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,10 @@ bool MString::StringAt(int start, int length, ... )
109109
do
110110
{
111111
test = va_arg(sstrings, char*);
112-
if(*test AND (target == test))
112+
if(*test AND (target == test)) {
113+
va_end(sstrings);
113114
return true;
115+
}
114116

115117
}while(strcmp(test, ""));
116118

dialogs/world_prefs/aliasdlg.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,7 @@ void CAliasDlg::DoDataExchange(CDataExchange* pDX)
171171
if (m_bRegexp)
172172
{
173173
if (!CheckRegularExpression (m_name, (m_bIgnoreCase ? 0 : PCRE_CASELESS)
174-
| (m_pDoc->m_bUTF_8 ? PCRE_UTF8 : 0)
175-
#if ALIASES_USE_UTF8
176-
| (m_pDoc->m_bUTF_8 ? PCRE_UTF8 : 0)
177-
#endif // ALIASES_USE_UTF8
178-
174+
| (m_pDoc->m_bUTF_8 ? PCRE_UTF8 : 0)
179175
))
180176
{ // failed check
181177
DDX_Text(pDX, IDC_ALIAS_NAME, m_name);

luacom/tCOMUtil.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,8 @@ ITypeLib* tCOMUtil::LoadTypeLibFromProgID(const char* ProgID,
367367
return NULL;
368368

369369
bool version_found = false;
370-
int version = -1;
371370

372-
if(major_version <= 0)
371+
if(major_version == 0)
373372
{
374373
if(sscanf(ProgID, "%*s.%*s.%d", &major_version) == 1)
375374
version_found = true;
@@ -471,6 +470,7 @@ ITypeLib* tCOMUtil::LoadTypeLibFromCLSID(CLSID clsid,
471470

472471
if(pcClsid)
473472
free(pcClsid);
473+
free(bLibID);
474474

475475
return NULL;
476476
}
@@ -496,8 +496,7 @@ ITypeLib* tCOMUtil::LoadTypeLibFromCLSID(CLSID clsid,
496496

497497
if(major_version > 0 &&
498498
(
499-
(!version_info_found) ||
500-
(version_info_found && found == 0)
499+
(!version_info_found) || (found == 0)
501500
)
502501
)
503502
{
@@ -513,8 +512,11 @@ ITypeLib* tCOMUtil::LoadTypeLibFromCLSID(CLSID clsid,
513512
&version_major,
514513
&version_minor);
515514

516-
if(!result)
515+
if(!result) {
516+
free(bLibID);
517+
free(wcTypelib);
517518
return NULL;
519+
}
518520
}
519521

520522
free(bLibID);
@@ -703,7 +705,6 @@ bool tCOMUtil::DelRegKey(const char *key,
703705
const char *subkey)
704706
{
705707

706-
bool ok = false;
707708
LONG ec = 0;
708709

709710
const int bufsize = 10000;

luacom/tLuaCOMConnPoints.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ tLuaCOMEnumConnPoints::tLuaCOMEnumConnPoints(IUnknown* pHostObj)
4444
cRefs = 0;
4545

4646
// Assign the Host Object pointer.
47-
pHostObj = pHostObj;
47+
this->pHostObj = pHostObj;
4848

4949
// Initialize the Connection Point enumerator variables.
5050
iEnumIndex = 0;
@@ -453,7 +453,7 @@ tLuaCOMConnPoint::tLuaCOMConnPoint(lua_State *p_L,
453453
// this connection point. Since this connection point object's lifetime
454454
// is geared to that of the connectable object there is no need to
455455
// AddRef the following copied pointer to the connectable object.
456-
pHostObj = pHostObj;
456+
this->pHostObj = pHostObj;
457457

458458
// Initialize the Connection Point variables.
459459
dwNextCookie = COOKIE_START_VALUE;
@@ -973,7 +973,7 @@ tLuaCOMEnumConnections::tLuaCOMEnumConnections(
973973
cRefs = 0;
974974

975975
// Assign the Host Object pointer.
976-
pHostObj = pHostObj;
976+
this->pHostObj = pHostObj;
977977

978978
// Initialize the Connection Point enumerator variables.
979979
iEnumIndex = 0;

luacom/tLuaVector.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ unsigned long tLuaVector::get_Dimensions()
5050
unsigned long tLuaVector::get_Nth_Dimension(unsigned long n)
5151
{
5252
// precond
53-
CHECKPRECOND(length >= 0 && n >= 0 && (n == 1 || elem_type == VECTOR));
53+
CHECKPRECOND(n == 1 || elem_type == VECTOR);
5454

5555
if(n == 1)
5656
return length;
@@ -323,7 +323,7 @@ void tLuaVector::InitVectorFromTable(lua_State* L, stkIndex table)
323323
// Itera em tabela ou userdata, criando LuaVectors recursivamente
324324
while(1)
325325
{
326-
CHECKPRECOND((length <= 0 || elem_type != UNKNOWN) &&
326+
CHECKPRECOND((elem_type != UNKNOWN) &&
327327
(length != 0 || elem_type == UNKNOWN));
328328

329329
lua_pushvalue(L, table);

mcdatetime.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ CmcDateTime CmcDateTime::operator-(const CmcDateTimeSpan& dateSpan) const
7070
} // end of CmcDateTime CmcDateTime::operator-
7171

7272

73-
const CmcDateTime& CmcDateTime::operator+=(const CmcDateTimeSpan dateSpan)
73+
const CmcDateTime& CmcDateTime::operator+=(const CmcDateTimeSpan& dateSpan)
7474
{
7575
*this = *this + dateSpan;
7676
return *this;
7777
} // end of CmcDateTime& CmcDateTime::operator+=
7878

79-
const CmcDateTime& CmcDateTime::operator-=(const CmcDateTimeSpan dateSpan)
79+
const CmcDateTime& CmcDateTime::operator-=(const CmcDateTimeSpan& dateSpan)
8080
{
8181
*this = *this - dateSpan;
8282
return *this;
@@ -392,10 +392,10 @@ CmcDateTimeSpan CmcDateTimeSpan::operator-(const CmcDateTimeSpan& dateSpan) cons
392392
return dateSpanTemp;
393393
}
394394

395-
const CmcDateTimeSpan& CmcDateTimeSpan::operator+=(const CmcDateTimeSpan dateSpan)
395+
const CmcDateTimeSpan& CmcDateTimeSpan::operator+=(const CmcDateTimeSpan& dateSpan)
396396
{ *this = *this + dateSpan; return *this; }
397397

398-
const CmcDateTimeSpan& CmcDateTimeSpan::operator-=(const CmcDateTimeSpan dateSpan)
398+
const CmcDateTimeSpan& CmcDateTimeSpan::operator-=(const CmcDateTimeSpan& dateSpan)
399399
{ *this = *this - dateSpan; return *this; }
400400
CmcDateTimeSpan CmcDateTimeSpan::operator-() const
401401
{ return -this->m_span; }

regexp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ class t_regexp
7474
};
7575

7676
// returns a named wildcard
77-
string GetWildcard (const string sName) const
77+
string GetWildcard (const string& sName) const
7878
{
7979
int iNumber;
8080
if (IsStringNumber (sName))

stdafx.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ inline string trim (const string & s, const string & t = SPACES)
682682

683683
// string find-and-replace
684684
inline string FindAndReplace
685-
(const string& source, const string target, const string replacement)
685+
(const string& source, const string& target, const string& replacement)
686686
{
687687
string str = source;
688688
string::size_type pos = 0, // where we are now

0 commit comments

Comments
 (0)