macmade / CFPP

C++ wrapper for CoreFoundation base classes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CF::Dictionary::ContainsKey crash if key is std::string

gregzo opened this issue · comments

Consider the following example:

CF::Dictionary dic;
dic << CF::Pair( "Key", "Value" );
CF::String value = dic[ "Key" ]; //no problem.
bool contains = dic.ContainsKey( "Key" ); //crash
contains = dic.ContainsKey( CF::String( "Key" ) ); //OK.

CF::Pair's ctor accepts std::string. CF::Dictionary's subscript operator accepts std::string too. Wouldn't it make sense for ContainsKey to behave the same?

That's not a std::string, but a const char *, which get converted as a CFTypeRef. That's why it crashes...

But yes, I think adding an overload could be nice... : )

Fixed in e743fd5