Commit 41887832 authored by Dimitri van Heesch's avatar Dimitri van Heesch

Fixed a number of issues (resource leaks, uninitialized members, etc) found by coverity

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