Permalink
Browse files

Fixed a number of issues (resource leaks, uninitialized members, etc)…

… found by coverity
  • Loading branch information...
Dimitri van Heesch
Dimitri van Heesch committed Aug 31, 2014
1 parent b59edd2 commit 41887832b90698df95e8d222cdc0a541ae2f2284
Showing with 42 additions and 36 deletions.
  1. +1 −1 qtools/qgstring.cpp
  2. +1 −0 qtools/qthread.cpp
  3. +2 −1 src/docparser.cpp
  4. +26 −27 src/doxygen.cpp
  5. +1 −0 src/htmlhelp.cpp
  6. +1 −1 src/index.cpp
  7. +1 −0 src/msc.cpp
  8. +3 −0 src/pre.l
  9. +6 −6 src/template.cpp
View
@@ -209,7 +209,7 @@ QGString &QGString::operator+=( const QGString &s )
assert(memSize>=len1+len2+1);
char *newData = memSize!=m_memSize ? (char*)realloc( m_data, memSize ) : m_data;
m_memSize = memSize;
if (m_data)
if (newData)
{
m_data = newData;
memcpy( m_data + len1, s, len2 + 1 );
View
@@ -52,6 +52,7 @@ QThread::~QThread()
QMutexLocker locker(&d->mutex);
if (d->running && !d->finished)
qWarning("QThread: Destroyed while thread is still running");
delete d;
}
bool QThread::isFinished() const
View
@@ -76,7 +76,8 @@ static const char *sectionLevelToName[] =
"section",
"subsection",
"subsubsection",
"paragraph"
"paragraph",
"subparagraph"
};
//---------------------------------------------------------------------------
View
@@ -2077,18 +2077,15 @@ static void findUsingDeclarations(EntryNav *rootNav)
usingCd->name().data(),nd?nd->name().data():fd->name().data());
}
if (usingCd) // add the class to the correct scope
if (nd)
{
if (nd)
{
//printf("Inside namespace %s\n",nd->name().data());
nd->addUsingDeclaration(usingCd);
}
else if (fd)
{
//printf("Inside file %s\n",fd->name().data());
fd->addUsingDeclaration(usingCd);
}
//printf("Inside namespace %s\n",nd->name().data());
nd->addUsingDeclaration(usingCd);
}
else if (fd)
{
//printf("Inside file %s\n",fd->name().data());
fd->addUsingDeclaration(usingCd);
}
}
@@ -4107,8 +4104,12 @@ static QDict<int> *getTemplateArgumentsInName(ArgumentList *templateArguments,co
*/
static ClassDef *findClassWithinClassContext(Definition *context,ClassDef *cd,const QCString &name)
{
FileDef *fd=cd->getFileDef();
ClassDef *result=0;
if (cd==0)
{
return result;
}
FileDef *fd=cd->getFileDef();
if (context && cd!=context)
{
result = getResolvedClass(context,0,name,0,0,TRUE,TRUE);
@@ -4121,7 +4122,7 @@ static ClassDef *findClassWithinClassContext(Definition *context,ClassDef *cd,co
{
result = getClass(name);
}
if (result==0 && cd &&
if (result==0 &&
(cd->getLanguage()==SrcLangExt_CSharp || cd->getLanguage()==SrcLangExt_Java) &&
name.find('<')!=-1)
{
@@ -4243,13 +4244,10 @@ static void findUsedClassesForClass(EntryNav *rootNav,
usedCd->setLanguage(masterCd->getLanguage());
Doxygen::hiddenClasses->append(usedName,usedCd);
}
if (usedCd)
{
if (isArtificial) usedCd->setArtificial(TRUE);
Debug::print(Debug::Classes,0," Adding used class `%s' (1)\n", usedCd->name().data());
instanceCd->addUsedClass(usedCd,md->name(),md->protection());
usedCd->addUsedByClass(instanceCd,md->name(),md->protection());
}
if (isArtificial) usedCd->setArtificial(TRUE);
Debug::print(Debug::Classes,0," Adding used class `%s' (1)\n", usedCd->name().data());
instanceCd->addUsedClass(usedCd,md->name(),md->protection());
usedCd->addUsedByClass(instanceCd,md->name(),md->protection());
}
}
}
@@ -6585,7 +6583,7 @@ static void findMember(EntryNav *rootNav,
funcType,funcName,funcArgs,exceptions,
root->protection,root->virt,
root->stat && !isMemberOf,
isMemberOf ? Foreign : isRelated ? Related : Member,
isMemberOf ? Foreign : Related,
mtype,
(root->tArgLists ? root->tArgLists->getLast() : 0),
funcArgs.isEmpty() ? 0 : root->argList);
@@ -8062,13 +8060,14 @@ static void generateClassList(ClassSDict &classSDict)
ClassDef *cd=cli.current();
//printf("cd=%s getOuterScope=%p global=%p\n",cd->name().data(),cd->getOuterScope(),Doxygen::globalScope);
if ((cd->getOuterScope()==0 || // <-- should not happen, but can if we read an old tag file
if (cd &&
(cd->getOuterScope()==0 || // <-- should not happen, but can if we read an old tag file
cd->getOuterScope()==Doxygen::globalScope // only look at global classes
) && !cd->isHidden() && !cd->isEmbeddedInOuterScope()
)
)
{
// skip external references, anonymous compounds and
// template instances
// skip external references, anonymous compounds and
// template instances
if ( cd->isLinkableInProject() && cd->templateMaster()==0)
{
msg("Generating docs for compound %s...\n",cd->name().data());
@@ -9003,9 +9002,9 @@ static void generateNamespaceDocs()
// for each class in the namespace...
ClassSDict::Iterator cli(*nd->getClassSDict());
for ( ; cli.current() ; ++cli )
ClassDef *cd;
for ( ; (cd=cli.current()) ; ++cli )
{
ClassDef *cd=cli.current();
if ( ( cd->isLinkableInProject() &&
cd->templateMaster()==0
) // skip external references, anonymous compounds and
View
@@ -281,6 +281,7 @@ HtmlHelp::HtmlHelp() : indexFileDict(1009)
HtmlHelp::~HtmlHelp()
{
if (m_fromUtf8!=(void *)(-1)) portable_iconv_close(m_fromUtf8);
delete index;
}
#if 0
/*! return a reference to the one and only instance of this class.
View
@@ -1640,7 +1640,7 @@ static void writeAnnotatedClassList(OutputList &ol)
static QCString letterToLabel(uint startLetter)
{
char s[10];
char s[11]; // max 0x12345678 + '\0'
if (startLetter>0x20 && startLetter<=0x7f) // printable ASCII character
{
s[0]=(char)startLetter;
View
@@ -74,6 +74,7 @@ static bool convertMapFile(FTextStream &t,const char *mapName,const QCString rel
t << externalRef(relPath,df->ref(),TRUE);
if (!df->file().isEmpty()) t << df->file() << Doxygen::htmlFileExtension;
if (!df->anchor().isEmpty()) t << "#" << df->anchor();
delete df;
}
else
{
View
@@ -207,6 +207,7 @@ class DefineManager
if (dpf==0)
{
dpf = new DefinesPerFile;
m_fileMap.insert(fileName,dpf);
}
dpf->addDefine(def);
}
@@ -223,6 +224,7 @@ class DefineManager
if (dpf==0)
{
dpf = new DefinesPerFile;
m_fileMap.insert(fromFileName,dpf);
}
dpf->addInclude(toFileName);
}
@@ -2283,6 +2285,7 @@ CHARLIT (("'"\\[0-7]{1,3}"'")|("'"\\."'")|("'"[^'\\\n]{1,4}"'"))
}
<DefName>{ID}/("\\\n")*"(" { // define with argument
//printf("Define() `%s'\n",yytext);
delete g_argDict;
g_argDict = new QDict<int>(31);
g_argDict->setAutoDelete(TRUE);
g_defArgs = 0;
View
@@ -1165,7 +1165,7 @@ class FilterAlphaIndex
}
static QCString keyToLabel(uint startLetter)
{
char s[10];
char s[11]; // 0x12345678 + '\0'
if (startLetter>0x20 && startLetter<=0x7f) // printable ASCII character
{
s[0]=tolower((char)startLetter);
@@ -2403,7 +2403,7 @@ TemplateVariant TemplateContextImpl::get(const QCString &name) const
warn(m_templateName,m_line,"using . on an object '%s' is not an struct or list",objName.data());
return TemplateVariant();
}
} while (i!=-1);
}
return v;
}
}
@@ -2860,7 +2860,7 @@ class TemplateNodeRange : public TemplateNodeCreator<TemplateNodeRange>
{
public:
TemplateNodeRange(TemplateParser *parser,TemplateNode *parent,int line,const QCString &data)
: TemplateNodeCreator<TemplateNodeRange>(parser,parent,line)
: TemplateNodeCreator<TemplateNodeRange>(parser,parent,line), m_down(FALSE)
{
TRACE(("{TemplateNodeRange(%s)\n",data.data()));
QCString start,end;
@@ -3030,7 +3030,7 @@ class TemplateNodeFor : public TemplateNodeCreator<TemplateNodeFor>
{
public:
TemplateNodeFor(TemplateParser *parser,TemplateNode *parent,int line,const QCString &data)
: TemplateNodeCreator<TemplateNodeFor>(parser,parent,line)
: TemplateNodeCreator<TemplateNodeFor>(parser,parent,line), m_reversed(FALSE)
{
TRACE(("{TemplateNodeFor(%s)\n",data.data()));
QCString exprStr;
@@ -3438,7 +3438,7 @@ class TemplateNodeCreate : public TemplateNodeCreator<TemplateNodeCreate>
{
public:
TemplateNodeCreate(TemplateParser *parser,TemplateNode *parent,int line,const QCString &data)
: TemplateNodeCreator<TemplateNodeCreate>(parser,parent,line)
: TemplateNodeCreator<TemplateNodeCreate>(parser,parent,line), m_templateExpr(0), m_fileExpr(0)
{
TRACE(("TemplateNodeCreate(%s)\n",data.data()));
ExpressionParser ep(parser,line);
@@ -4013,7 +4013,7 @@ class TemplateNodeMarkers : public TemplateNodeCreator<TemplateNodeMarkers>
{
public:
TemplateNodeMarkers(TemplateParser *parser,TemplateNode *parent,int line,const QCString &data)
: TemplateNodeCreator<TemplateNodeMarkers>(parser,parent,line)
: TemplateNodeCreator<TemplateNodeMarkers>(parser,parent,line), m_listExpr(0), m_patternExpr(0)
{
TRACE(("{TemplateNodeMarkers(%s)\n",data.data()));
int i = data.find(" in ");

0 comments on commit 4188783

Please sign in to comment.