Skip to content

Commit 8723f80

Browse files
committed
issue #7216: non-const getGroupDef() called on aliased member (cleanup + null pointer fix)
1 parent b409bd0 commit 8723f80

14 files changed

+30
-52
lines changed

src/classdef.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,14 +1276,14 @@ void ClassDefImpl::distributeMemberGroupDocumentation()
12761276

12771277
void ClassDefImpl::findSectionsInDocumentation()
12781278
{
1279-
docFindSections(documentation(),this,0,docFile());
1279+
docFindSections(documentation(),this,docFile());
12801280
if (m_impl->memberGroupSDict)
12811281
{
12821282
MemberGroupSDict::Iterator mgli(*m_impl->memberGroupSDict);
12831283
MemberGroup *mg;
12841284
for (;(mg=mgli.current());++mgli)
12851285
{
1286-
mg->findSectionsInDocumentation();
1286+
mg->findSectionsInDocumentation(this);
12871287
}
12881288
}
12891289
QListIterator<MemberList> mli(m_impl->memberLists);
@@ -1292,7 +1292,7 @@ void ClassDefImpl::findSectionsInDocumentation()
12921292
{
12931293
if ((ml->listType()&MemberListType_detailedLists)==0)
12941294
{
1295-
ml->findSectionsInDocumentation();
1295+
ml->findSectionsInDocumentation(this);
12961296
}
12971297
}
12981298
}

src/docparser.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7797,10 +7797,9 @@ DocText *validatingParseText(const char *input)
77977797
}
77987798

77997799
void docFindSections(const char *input,
7800-
Definition *d,
7801-
MemberGroup *mg,
7800+
const Definition *d,
78027801
const char *fileName)
78037802
{
7804-
doctokenizerYYFindSections(input,d,mg,fileName);
7803+
doctokenizerYYFindSections(input,d,fileName);
78057804
}
78067805

src/docparser.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ DocText *validatingParseText(const char *input);
7777

7878
/*! Searches for section and anchor commands in the input */
7979
void docFindSections(const char *input,
80-
Definition *d,
81-
MemberGroup *m,
80+
const Definition *d,
8281
const char *fileName);
8382

8483
//---------------------------------------------------------------------------

src/doctokenizer.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "htmlattrib.h"
2626

2727
class Definition;
28-
class MemberGroup;
2928

3029
enum Tokens
3130
{
@@ -122,8 +121,8 @@ extern FILE *doctokenizerYYin;
122121
const char *tokToString(int token);
123122

124123
// operations on the scanner
125-
void doctokenizerYYFindSections(const char *input,Definition *d,
126-
MemberGroup *mg,const char *fileName);
124+
void doctokenizerYYFindSections(const char *input,const Definition *d,
125+
const char *fileName);
127126
void doctokenizerYYinit(const char *input,const char *fileName);
128127
void doctokenizerYYcleanup();
129128
void doctokenizerYYpushContext();

src/doctokenizer.l

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ static bool g_insidePre;
5757
static int g_sharpCount=0;
5858

5959
// context for section finding phase
60-
static Definition *g_definition;
61-
static MemberGroup *g_memberGroup;
60+
static const Definition *g_definition;
6261
static QCString g_secLabel;
6362
static QCString g_secTitle;
6463
static SectionInfo::SectionType g_secType;
@@ -159,11 +158,7 @@ static void processSection()
159158
{
160159
//printf("%s: found section/anchor with name '%s'\n",g_fileName.data(),g_secLabel.data());
161160
QCString file;
162-
if (g_memberGroup)
163-
{
164-
file = g_memberGroup->parent()->getOutputFileBase();
165-
}
166-
else if (g_definition)
161+
if (g_definition)
167162
{
168163
file = g_definition->getOutputFileBase();
169164
}
@@ -1369,16 +1364,15 @@ REFWORD_NOCV {FILEMASK}|{LABELID}|{REFWORD2_NOCV}|{REFWORD3}|{REFWORD4_NOCV}
13691364

13701365
//--------------------------------------------------------------------------
13711366

1372-
void doctokenizerYYFindSections(const char *input,Definition *d,
1373-
MemberGroup *mg,const char *fileName)
1367+
void doctokenizerYYFindSections(const char *input,const Definition *d,
1368+
const char *fileName)
13741369
{
13751370
if (input==0) return;
13761371
printlex(yy_flex_debug, TRUE, __FILE__, fileName);
13771372
g_inputString = input;
13781373
//printf("parsing --->'%s'<---\n",input);
13791374
g_inputPos = 0;
13801375
g_definition = d;
1381-
g_memberGroup = mg;
13821376
g_fileName = fileName;
13831377
BEGIN(St_Sections);
13841378
doctokenizerYYlineno = 1;

src/filedef.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,14 +312,14 @@ void FileDefImpl::distributeMemberGroupDocumentation()
312312

313313
void FileDefImpl::findSectionsInDocumentation()
314314
{
315-
docFindSections(documentation(),this,0,docFile());
315+
docFindSections(documentation(),this,docFile());
316316
if (m_memberGroupSDict)
317317
{
318318
MemberGroupSDict::Iterator mgli(*m_memberGroupSDict);
319319
MemberGroup *mg;
320320
for (;(mg=mgli.current());++mgli)
321321
{
322-
mg->findSectionsInDocumentation();
322+
mg->findSectionsInDocumentation(this);
323323
}
324324
}
325325

@@ -329,7 +329,7 @@ void FileDefImpl::findSectionsInDocumentation()
329329
{
330330
if (ml->listType()&MemberListType_declarationLists)
331331
{
332-
ml->findSectionsInDocumentation();
332+
ml->findSectionsInDocumentation(this);
333333
}
334334
}
335335
}

src/groupdef.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -236,12 +236,12 @@ void GroupDefImpl::distributeMemberGroupDocumentation()
236236

237237
void GroupDefImpl::findSectionsInDocumentation()
238238
{
239-
docFindSections(documentation(),this,0,docFile());
239+
docFindSections(documentation(),this,docFile());
240240
MemberGroupSDict::Iterator mgli(*memberGroupSDict);
241241
MemberGroup *mg;
242242
for (;(mg=mgli.current());++mgli)
243243
{
244-
mg->findSectionsInDocumentation();
244+
mg->findSectionsInDocumentation(this);
245245
}
246246

247247
QListIterator<MemberList> mli(m_memberLists);
@@ -250,7 +250,7 @@ void GroupDefImpl::findSectionsInDocumentation()
250250
{
251251
if (ml->listType()&MemberListType_declarationLists)
252252
{
253-
ml->findSectionsInDocumentation();
253+
ml->findSectionsInDocumentation(this);
254254
}
255255
}
256256
}

src/memberdef.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4923,7 +4923,7 @@ ClassDef *MemberDefImpl::accessorClass() const
49234923

49244924
void MemberDefImpl::findSectionsInDocumentation()
49254925
{
4926-
docFindSections(documentation(),this,0,docFile());
4926+
docFindSections(documentation(),this,docFile());
49274927
}
49284928

49294929
void MemberDefImpl::enableCallGraph(bool e)

src/membergroup.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -351,10 +351,10 @@ void MemberGroup::addListReferences(Definition *def)
351351
}
352352
}
353353

354-
void MemberGroup::findSectionsInDocumentation()
354+
void MemberGroup::findSectionsInDocumentation(const Definition *d)
355355
{
356-
docFindSections(doc,0,this,m_docFile);
357-
memberList->findSectionsInDocumentation();
356+
docFindSections(doc,d,m_docFile);
357+
memberList->findSectionsInDocumentation(d);
358358
}
359359

360360
void MemberGroup::setRefItems(const QList<ListItemInfo> *sli)

src/membergroup.h

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,7 @@ class MemberGroup
7171
void countDocMembers();
7272
int countGroupedInheritedMembers(MemberListType lt);
7373
void distributeMemberGroupDocumentation();
74-
void findSectionsInDocumentation();
75-
/*
76-
int varCount() const;
77-
int funcCount() const;
78-
int enumCount() const;
79-
int enumValueCount() const;
80-
int typedefCount() const;
81-
int sequenceCount() const;
82-
int dictionaryCount() const;
83-
int protoCount() const;
84-
int defineCount() const;
85-
int friendCount() const;
86-
*/
74+
void findSectionsInDocumentation(const Definition *d);
8775
int numDecMembers() const;
8876
int numDecEnumValues() const;
8977
int numDocMembers() const;
@@ -94,7 +82,6 @@ class MemberGroup
9482
void addListReferences(Definition *d);
9583
void setRefItems(const QList<ListItemInfo> *sli);
9684
MemberList *members() const { return memberList; }
97-
const Definition *parent() const { return m_parent; }
9885
QCString anchor() const;
9986

10087
QCString docFile() const { return m_docFile; }

src/memberlist.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ void MemberList::addListReferences(Definition *def)
961961
}
962962
}
963963

964-
void MemberList::findSectionsInDocumentation()
964+
void MemberList::findSectionsInDocumentation(const Definition *d)
965965
{
966966
MemberListIterator mli(*this);
967967
MemberDef *md;
@@ -975,7 +975,7 @@ void MemberList::findSectionsInDocumentation()
975975
MemberGroup *mg;
976976
for (;(mg=mgli.current());++mgli)
977977
{
978-
mg->findSectionsInDocumentation();
978+
mg->findSectionsInDocumentation(d);
979979
}
980980
}
981981
}

src/memberlist.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class MemberList : private QList<MemberDef>
8989
void setInGroup(bool inGroup) { m_inGroup=inGroup; }
9090
void setInFile(bool inFile) { m_inFile=inFile; }
9191
void addListReferences(Definition *def);
92-
void findSectionsInDocumentation();
92+
void findSectionsInDocumentation(const Definition *d);
9393
void setNeedsSorting(bool b);
9494
MemberGroupList *getMemberGroupList() const { return memberGroupList; }
9595
void setAnonymousEnumType();

src/namespacedef.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -349,20 +349,20 @@ void NamespaceDefImpl::distributeMemberGroupDocumentation()
349349

350350
void NamespaceDefImpl::findSectionsInDocumentation()
351351
{
352-
docFindSections(documentation(),this,0,docFile());
352+
docFindSections(documentation(),this,docFile());
353353
MemberGroupSDict::Iterator mgli(*memberGroupSDict);
354354
MemberGroup *mg;
355355
for (;(mg=mgli.current());++mgli)
356356
{
357-
mg->findSectionsInDocumentation();
357+
mg->findSectionsInDocumentation(this);
358358
}
359359
QListIterator<MemberList> mli(m_memberLists);
360360
MemberList *ml;
361361
for (mli.toFirst();(ml=mli.current());++mli)
362362
{
363363
if (ml->listType()&MemberListType_declarationLists)
364364
{
365-
ml->findSectionsInDocumentation();
365+
ml->findSectionsInDocumentation(this);
366366
}
367367
}
368368
}

src/pagedef.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ PageDefImpl::~PageDefImpl()
9999

100100
void PageDefImpl::findSectionsInDocumentation()
101101
{
102-
docFindSections(documentation(),this,0,docFile());
102+
docFindSections(documentation(),this,docFile());
103103
}
104104

105105
GroupDef *PageDefImpl::getGroupDef() const

0 commit comments

Comments
 (0)