ObjFW  Diff

Differences From Artifact [fd771ca2dd]:

To Artifact [927cabf999]:

  • File src/OFString+Serialization.m — part of check-in [e1e7ffa903] at 2011-09-22 23:25:42 on branch trunk — Exceptions are now autoreleased.

    This is safe as an "exception loop" can't happen, since if allocating
    an exception fails, it throws an OFAllocFailedException which is
    preallocated and can always be thrown.

    So, the worst case would be that an autorelease of an exception fails,
    triggering an OFOutOfMemoryException for which there is no memory,
    resulting in an OFAllocFailedException to be thrown. (user: js, size: 1723) [annotate] [blame] [check-ins using]


36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
	OFXMLElement *root;
	OFArray *elements;
	id object;

	@try {
		root = [OFXMLElement elementWithXMLString: self];
	} @catch (OFMalformedXMLException *e) {
		[e release];
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
	} @catch (OFUnboundNamespaceException *e) {
		[e release];
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];
	}

	elements = [root elementsForNamespace: OF_SERIALIZATION_NS];

	if ([elements count] != 1)
		@throw [OFInvalidArgumentException newWithClass: isa
						       selector: _cmd];

	object = [[elements firstObject] objectByDeserializing];

	[object retain];
	[pool release];
	[object autorelease];

	return object;
}
@end







<
|
|

<
|
|





|
|










36
37
38
39
40
41
42

43
44
45

46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
	OFXMLElement *root;
	OFArray *elements;
	id object;

	@try {
		root = [OFXMLElement elementWithXMLString: self];
	} @catch (OFMalformedXMLException *e) {

		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];
	} @catch (OFUnboundNamespaceException *e) {

		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];
	}

	elements = [root elementsForNamespace: OF_SERIALIZATION_NS];

	if ([elements count] != 1)
		@throw [OFInvalidArgumentException exceptionWithClass: isa
							     selector: _cmd];

	object = [[elements firstObject] objectByDeserializing];

	[object retain];
	[pool release];
	[object autorelease];

	return object;
}
@end