Skip to content

Commit 607a36a

Browse files
author
giraffedata
committed
Fix handling of non-pointing autoObjectPtr
git-svn-id: file:///var/tmp/xmlrpc/svn/trunk/xmlrpc-c@1015 adbb7d4b-a73a-0410-a071-c5f57c452bd4
1 parent fd5e8e3 commit 607a36a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/cpp/girmem.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,10 @@ autoObjectPtr::unpoint() {
120120
if (this->objectP) {
121121
bool dead;
122122
this->objectP->decref(&dead);
123-
if (dead)
123+
if (dead) {
124124
delete(this->objectP);
125+
this->objectP = NULL;
126+
}
125127
}
126128
}
127129

@@ -140,7 +142,8 @@ autoObjectPtr::operator=(autoObjectPtr const& source) {
140142
} else {
141143
this->unpoint();
142144
this->objectP = source.objectP;
143-
this->objectP->incref();
145+
if (this->objectP)
146+
this->objectP->incref();
144147
}
145148
return *this;
146149
}
@@ -149,6 +152,9 @@ autoObjectPtr::operator=(autoObjectPtr const& source) {
149152

150153
autoObject *
151154
autoObjectPtr::operator->() const {
155+
if (this->objectP == NULL)
156+
throw(error("attempt to dereference autoObjectPtr "
157+
"which does not point to anything"));
152158
return this->objectP;
153159
}
154160

0 commit comments

Comments
 (0)