ObjFW  Check-in [b464ddcda5]

Overview
Comment:Handle reads with a returned size of 0 safely in -[readLine].

Before, it could call memcpy with size of 0 on a pointer that might be
NULL and thus might be undefined behaviour. This way, it's compatible to
the OFSocket change in the commit before.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: b464ddcda54bf089c44cb3f325592927bef2ccbacd14796cc99690f8078af9bb
User & Date: js on 2009-06-09 13:21:12
Other Links: manifest | tags
Context
2009-06-09
17:19
Rename ERROR to SYNC_ERR in objc_sync.m to prevent conflicts. check-in: e58b9661a5 user: js tags: trunk
13:21
Handle reads with a returned size of 0 safely in -[readLine]. check-in: b464ddcda5 user: js tags: trunk
13:10
Implement -[atEndOfStream] for OFSocket. check-in: 41d7910a65 user: js tags: trunk
Changes

Modified src/OFStream.m from [a25cf5ad1f] to [b556a211fc].

188
189
190
191
192
193
194






195


196
197
198
199
200
201
202
188
189
190
191
192
193
194
195
196
197
198
199
200

201
202
203
204
205
206
207
208
209







+
+
+
+
+
+
-
+
+







		@try {
			cache = [self resizeMemory: cache
					    toSize: cache_len + len];
		} @catch (OFException *e) {
			[self freeMemory: tmp];
			@throw e;
		}

		/*
		 * It's possible that cache_len + len is 0 and thus cache was
		 * set to NULL by resizeMemory:toSize:.
		 */
		if (cache != NULL)
		memcpy(cache + cache_len, tmp, len);
			memcpy(cache + cache_len, tmp, len);

		cache_len += len;
	}
}

- (size_t)writeNBytes: (size_t)size
	   fromBuffer: (const char*)buf
{