Index: src/OFDictionary.h ================================================================== --- src/OFDictionary.h +++ src/OFDictionary.h @@ -55,11 +55,11 @@ * Sets a key to an object. A key can be any object. * * \param key The key to set * \param obj The object to set the key to */ -- set: (OFObject*)key +- set: (OFObject *)key to: (OFObject*)obj; /** * \param key The key whose object should be returned * \return The object for the given key or nil if the key was not found Index: src/OFDictionary.m ================================================================== --- src/OFDictionary.m +++ src/OFDictionary.m @@ -97,15 +97,15 @@ [data[i] release]; [super dealloc]; } -- set: (OFObject*)key +- set: (OFObject *)key to: (OFObject*)obj { uint32_t hash; - of_list_object_t *iter; + of_list_object_t *iter, *key_obj; if (key == nil || obj == nil) @throw [OFInvalidArgumentException newWithClass: isa andSelector: _cmd]; @@ -122,12 +122,23 @@ return self; } } - [data[hash] append: key]; - [data[hash] append: obj]; + key = [key copy]; + @try { + key_obj = [data[hash] append: key]; + } @finally { + [key release]; + } + + @try { + [data[hash] append: obj]; + } @catch (OFException *e) { + [data[hash] remove: key_obj]; + @throw e; + } return self; } - (id)get: (OFObject*)key