41 lines
1 KiB
Diff
41 lines
1 KiB
Diff
|
upstream PR: https://github.com/doxygen/doxygen/pull/8739
|
||
|
|
||
|
What was happening is that the TextStream object is reused for multiple
|
||
|
different files. Therefore, when one calls setStream(nullptr) or
|
||
|
setFile(nullptr), m_f or m_s will, respectively, still contain a pointer
|
||
|
to the previous member, which is used when one calls setFile() or
|
||
|
setStream() again, since these methods will call flush().
|
||
|
|
||
|
For example, a program doing
|
||
|
|
||
|
s.setFile(f1);
|
||
|
s.setStream(nullptr);
|
||
|
fclose(f1);
|
||
|
s.setFile(f2);
|
||
|
|
||
|
will call fwrite(f1, ...). This pattern can be observed in many parts of
|
||
|
Doxygen, so fixing it in TextStream itself by always zeroing the other
|
||
|
pointer is the simplest fix.
|
||
|
|
||
|
diff --git a/src/textstream.h b/src/textstream.h
|
||
|
index 161ce7fe..38027ec0 100644
|
||
|
--- a/src/textstream.h
|
||
|
+++ b/src/textstream.h
|
||
|
@@ -67,11 +67,13 @@ class TextStream final
|
||
|
{
|
||
|
flush();
|
||
|
m_s = s;
|
||
|
+ m_f = nullptr;
|
||
|
}
|
||
|
|
||
|
void setFile(FILE *f)
|
||
|
{
|
||
|
flush();
|
||
|
+ m_s = nullptr;
|
||
|
m_f = f;
|
||
|
}
|
||
|
|
||
|
--
|
||
|
2.33.0
|
||
|
|