ObjFW  Check-in [508399eac1]

Overview
Comment:Prevent loss of data due to wrong encoding in -[readLine].
This allows reading again with the correct encoding.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 508399eac137acba943ac8b74b487e4987fe3d37a59373121041670b4949ea2d
User & Date: js on 2010-08-24 19:37:56
Other Links: manifest | tags
Context
2010-08-25
11:22
Add warning to doc about collections not retaining and autoreleasing. check-in: 91ccd70c55 user: js tags: trunk
2010-08-24
19:37
Prevent loss of data due to wrong encoding in -[readLine].
This allows reading again with the correct encoding.
check-in: 508399eac1 user: js tags: trunk
19:24
Fix a bug in +[stringWithPath:] that led to broken unicode. check-in: 2328f5eeb2 user: js tags: trunk
Changes

Modified src/OFStream.m from [5b369f2077] to [0bce414eb0].

312
313
314
315
316
317
318


















319
320
321
322
323
324
325
						ret_len--;

					@try {
						ret = [OFString
						    stringWithCString: ret_c
							     encoding: encoding
							       length: ret_len];


















					} @finally {
						[self freeMemory: ret_c];
					}

					tmp2 = [self
					    allocMemoryWithSize: len - i - 1];
					if (tmp2 != NULL)







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
						ret_len--;

					@try {
						ret = [OFString
						    stringWithCString: ret_c
							     encoding: encoding
							       length: ret_len];
					} @catch (OFException *e) {
						/*
						 * Append data to cache to
						 * prevent loss of data due to
						 * wrong encoding.
						 */
						cache = [self
						    resizeMemory: cache
							  toSize: cacheLen +
								  len];

						if (cache != NULL)
							memcpy(cache + cacheLen,
							    tmp, len);

						cacheLen += len;

						@throw e;
					} @finally {
						[self freeMemory: ret_c];
					}

					tmp2 = [self
					    allocMemoryWithSize: len - i - 1];
					if (tmp2 != NULL)