ObjFW  Check-in [fa81b2657c]

Overview
Comment:Fix exception handling in of_asprintf.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: fa81b2657ccfa4d751a848b72760b289eb7bb846b51348fa366616005794d803
User & Date: js on 2011-12-26 16:24:15
Other Links: manifest | tags
Context
2011-12-26
16:38
Add a note about the lifetime of the result of -[UTF8String]. check-in: 55bba95bce user: js tags: trunk
16:24
Fix exception handling in of_asprintf. check-in: fa81b2657c user: js tags: trunk
2011-12-24
19:28
Don't check for -fgnu89-inline when using Clang. check-in: 1b60fffb9d user: js tags: trunk
Changes

Modified src/of_asprintf.m from [3dba5d325a] to [231103bb7a].

277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298



299
300

301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
	char *tmp = NULL;
	int tmpLen = 0;

	if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
		return false;

	switch (ctx->format[ctx->i]) {
	case '@':;
		OFAutoreleasePool *pool;

		ctx->subformat[ctx->subformatLen - 1] = 's';

		@try {
			pool = [[OFAutoreleasePool alloc] init];
		} @catch (id e) {
			return false;
		}

		@try {
			id object;

			if ((object = va_arg(ctx->arguments, id)) != nil)



				tmpLen = asprintf(&tmp, ctx->subformat,
				    [[object description] UTF8String]);

			else
				tmpLen = asprintf(&tmp, ctx->subformat,
				    "(nil)");
		} @catch (id e) {
			free(ctx->buffer);
			@throw e;
		} @finally {
			[pool release];
		}

		break;
	case 'd':
	case 'i':
		switch (ctx->lengthModifier) {
		case LENGTH_MODIFIER_NONE:







|
<
<


<
<
<
<
<
<



|
>
>
>


>
|





<
<







277
278
279
280
281
282
283
284


285
286






287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302


303
304
305
306
307
308
309
	char *tmp = NULL;
	int tmpLen = 0;

	if (!appendSubformat(ctx, ctx->format + ctx->i, 1))
		return false;

	switch (ctx->format[ctx->i]) {
	case '@':


		ctx->subformat[ctx->subformatLen - 1] = 's';







		@try {
			id object;

			if ((object = va_arg(ctx->arguments, id)) != nil) {
				OFAutoreleasePool *pool;

				pool = [[OFAutoreleasePool alloc] init];
				tmpLen = asprintf(&tmp, ctx->subformat,
				    [[object description] UTF8String]);
				[pool release];
			} else
				tmpLen = asprintf(&tmp, ctx->subformat,
				    "(nil)");
		} @catch (id e) {
			free(ctx->buffer);
			@throw e;


		}

		break;
	case 'd':
	case 'i':
		switch (ctx->lengthModifier) {
		case LENGTH_MODIFIER_NONE: