summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDimitri van Heesch <dimitri@stack.nl>2014-08-31 14:52:19 (GMT)
committerDimitri van Heesch <dimitri@stack.nl>2014-08-31 14:52:19 (GMT)
commit41887832b90698df95e8d222cdc0a541ae2f2284 (patch)
tree9ac6b9d9f07d8c5821fdd1b7d689db594a09414e
parentb59edd279f887e55b162ae1b1c7bce4b2ca29dab (diff)
downloadDoxygen-41887832b90698df95e8d222cdc0a541ae2f2284.zip
Doxygen-41887832b90698df95e8d222cdc0a541ae2f2284.tar.gz
Doxygen-41887832b90698df95e8d222cdc0a541ae2f2284.tar.bz2
Fixed a number of issues (resource leaks, uninitialized members, etc) found by coverity
-rw-r--r--qtools/qgstring.cpp2
-rw-r--r--qtools/qthread.cpp1
-rw-r--r--src/docparser.cpp3
-rw-r--r--src/doxygen.cpp53
-rw-r--r--src/htmlhelp.cpp1
-rw-r--r--src/index.cpp2
-rw-r--r--src/msc.cpp1
-rw-r--r--src/pre.l3
-rw-r--r--src/template.cpp12
9 files changed, 42 insertions, 36 deletions
diff --git a/qtools/qgstring.cpp b/qtools/qgstring.cpp
index 85dd879..8b15675 100644
--- a/qtools/qgstring.cpp
+++ b/qtools/qgstring.cpp
@@ -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 );
diff --git a/qtools/qthread.cpp b/qtools/qthread.cpp
index db2a0de..02c99f2 100644
--- a/qtools/qthread.cpp
+++ b/qtools/qthread.cpp
@@ -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
diff --git a/src/docparser.cpp b/src/docparser.cpp
index 3110779..144dd24 100644
--- a/src/docparser.cpp
+++ b/src/docparser.cpp
@@ -76,7 +76,8 @@ static const char *sectionLevelToName[] =
"section",
"subsection",
"subsubsection",
- "paragraph"
+ "paragraph",
+ "subparagraph"
};
//---------------------------------------------------------------------------
diff --git a/src/doxygen.cpp b/src/doxygen.cpp
index 4a46172..8b72f86 100644
--- a/src/doxygen.cpp
+++ b/src/doxygen.cpp
@@ -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
diff --git a/src/htmlhelp.cpp b/src/htmlhelp.cpp
index c1e535d..2629ab3 100644
--- a/src/htmlhelp.cpp
+++ b/src/htmlhelp.cpp
@@ -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.
diff --git a/src/index.cpp b/src/index.cpp
index c1c2837..ff347e3 100644
--- a/src/index.cpp
+++ b/src/index.cpp
@@ -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;
diff --git a/src/msc.cpp b/src/msc.cpp
index ebbba0f..f9e919c 100644
--- a/src/msc.cpp
+++ b/src/msc.cpp
@@ -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
{
diff --git a/src/pre.l b/src/pre.l
index c3eeb2a..ebc6cf8 100644
--- a/src/pre.l
+++ b/src/pre.l
@@ -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;
diff --git a/src/template.cpp b/src/template.cpp
index cec2e3c..942d833 100644
--- a/src/template.cpp
+++ b/src/template.cpp
@@ -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 ");