]> git.saurik.com Git - wxWidgets.git/blob - src/common/archive.cpp
fixing overrelease and out-of-bounds write, fixes #13725
[wxWidgets.git] / src / common / archive.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/archive.cpp
3 // Purpose: Streams for archive formats
4 // Author: Mike Wetherell
5 // RCS-ID: $Id$
6 // Copyright: (c) Mike Wetherell
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
12
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16
17 #if wxUSE_STREAMS && wxUSE_ARCHIVE_STREAMS
18
19 #include "wx/archive.h"
20
21 IMPLEMENT_ABSTRACT_CLASS(wxArchiveEntry, wxObject)
22 IMPLEMENT_ABSTRACT_CLASS(wxArchiveClassFactory, wxFilterClassFactoryBase)
23
24
25 /////////////////////////////////////////////////////////////////////////////
26 // wxArchiveInputStream
27
28 wxArchiveInputStream::wxArchiveInputStream(wxInputStream& stream,
29 wxMBConv& conv)
30 : wxFilterInputStream(stream),
31 m_conv(conv)
32 {
33 }
34
35 wxArchiveInputStream::wxArchiveInputStream(wxInputStream *stream,
36 wxMBConv& conv)
37 : wxFilterInputStream(stream),
38 m_conv(conv)
39 {
40 }
41
42
43 /////////////////////////////////////////////////////////////////////////////
44 // wxArchiveOutputStream
45
46 wxArchiveOutputStream::wxArchiveOutputStream(wxOutputStream& stream,
47 wxMBConv& conv)
48 : wxFilterOutputStream(stream),
49 m_conv(conv)
50 {
51 }
52
53 wxArchiveOutputStream::wxArchiveOutputStream(wxOutputStream *stream,
54 wxMBConv& conv)
55 : wxFilterOutputStream(stream),
56 m_conv(conv)
57 {
58 }
59
60
61 /////////////////////////////////////////////////////////////////////////////
62 // wxArchiveEntry
63
64 void wxArchiveEntry::SetNotifier(wxArchiveNotifier& notifier)
65 {
66 UnsetNotifier();
67 m_notifier = &notifier;
68 m_notifier->OnEntryUpdated(*this);
69 }
70
71 wxArchiveEntry& wxArchiveEntry::operator=(const wxArchiveEntry& WXUNUSED(e))
72 {
73 m_notifier = NULL;
74 return *this;
75 }
76
77
78 /////////////////////////////////////////////////////////////////////////////
79 // wxArchiveClassFactory
80
81 wxArchiveClassFactory *wxArchiveClassFactory::sm_first = NULL;
82
83 void wxArchiveClassFactory::Remove()
84 {
85 if (m_next != this)
86 {
87 wxArchiveClassFactory **pp = &sm_first;
88
89 while (*pp != this)
90 pp = &(*pp)->m_next;
91
92 *pp = m_next;
93
94 m_next = this;
95 }
96 }
97
98 #endif // wxUSE_STREAMS && wxUSE_ARCHIVE_STREAMS