File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -120,8 +120,10 @@ autoObjectPtr::unpoint() {
120
120
if (this ->objectP ) {
121
121
bool dead;
122
122
this ->objectP ->decref (&dead);
123
- if (dead)
123
+ if (dead) {
124
124
delete (this ->objectP );
125
+ this ->objectP = NULL ;
126
+ }
125
127
}
126
128
}
127
129
@@ -140,7 +142,8 @@ autoObjectPtr::operator=(autoObjectPtr const& source) {
140
142
} else {
141
143
this ->unpoint ();
142
144
this ->objectP = source.objectP ;
143
- this ->objectP ->incref ();
145
+ if (this ->objectP )
146
+ this ->objectP ->incref ();
144
147
}
145
148
return *this ;
146
149
}
@@ -149,6 +152,9 @@ autoObjectPtr::operator=(autoObjectPtr const& source) {
149
152
150
153
autoObject *
151
154
autoObjectPtr::operator ->() const {
155
+ if (this ->objectP == NULL )
156
+ throw (error (" attempt to dereference autoObjectPtr "
157
+ " which does not point to anything" ));
152
158
return this ->objectP ;
153
159
}
154
160
You can’t perform that action at this time.
0 commit comments