Opened 12 years ago

Closed 12 years ago

Last modified 2 years ago

#8966 closed patch

Wrong type promotion for SharedPtr

Reported by: peres Owned by: lordhoto
Priority: blocker Component: --Other--
Keywords: Cc:
Game:

Description

When a SharedPtr<X> is used as the contained type of a Common::List, the remove() method on the latter won't behave as expected.

Instead of invoking SharedPtr::operator==() as defined in common/ptr.h, the comparison at line 206 in common/list.h just promotes both operands to bool, and then compares them. This in turns happen to be true except when only one of the pointers is not initialized, yielding funny results that are easy to imagine.

The attached patch changes the definition of SharedPtr::operator==() to be a member of SharedPtr to fix the problem above.

I hope I got the patch in the right format.

Ticket imported from: #2641592. Ticket imported from: patches/1071.

Attachments (1)

ptr-fix.patch (915 bytes ) - added by peres 12 years ago.
Makes operator==() a member of SharedPtr.

Download all attachments as: .zip

Change History (4)

by peres, 12 years ago

Attachment: ptr-fix.patch added

Makes operator==() a member of SharedPtr.

comment:1 by lordhoto, 12 years ago

Status: newclosed

comment:2 by lordhoto, 12 years ago

Committed with a slight formatting change. Thanks for the patch.

comment:3 by digitall, 2 years ago

Component: --Other--
Note: See TracTickets for help on using tickets.