diff options
author | 2010-10-03 12:30:21 +0200 | |
---|---|---|
committer | 2011-02-12 14:17:47 +0100 | |
commit | be225ca1b627eb4dfc1c2e718f3f392695baeb22 (patch) | |
tree | 07739f0e04e6b66bfa6246924b0c3462faca5a25 /test/plist_test.c | |
parent | 0866710e35d54ce6d6913cc64998f414096f50d1 (diff) | |
download | libplist-be225ca1b627eb4dfc1c2e718f3f392695baeb22.tar.gz libplist-be225ca1b627eb4dfc1c2e718f3f392695baeb22.tar.bz2 |
Fix Dictionary copy constructor
While iterating over all the keys stored in the source Dictionary
to copy them to create the copied Dictonary, the name of the key
being copied was only set to a non-NULL value for the first key
we copy. This was then leading to an assertion when trying to
create a std::string from a NULL pointer. Simple test-case:
int main()
{
PList::Dictionary a;
PList::String b("Hello");
PList::String c("Hi!");
PList::Dictionary d;
a.Insert("Key", &b);
a.Insert("Another Key", &c);
std::cout << a.ToXml() << std::endl;
d.Insert("dictionary", &a); //CRAAAAAAAAASH!
std::cout << d.ToXml() << std::endl;
return 0;
}
/* Output:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Key</key>
<string>Hello</string>
<key>Another Key</key>
<string>Hi!</string>
</dict>
</plist>
terminate called after throwing an instance of 'std::logic_error'
what(): basic_string::_S_construct NULL not valid
*/
Signed-off-by: Martin Szulecki <opensuse@sukimashita.com>
Diffstat (limited to 'test/plist_test.c')
0 files changed, 0 insertions, 0 deletions