ObjFW  Check-in [16ec7469b8]

Overview
Comment:Don't call strlen() in -[initWithCString:encoding:length:].

This can cause trouble when we try to create a string from a buffer
which is not \0-terminated. In these cases, we would need to
\0-terminate it, which would be quite inconvenient.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 16ec7469b8f88fe31e9f9c2ab5767ceea82af9016318a47245ad9ed904860ee8
User & Date: js on 2009-11-01 19:46:22
Other Links: manifest | tags
Context
2009-11-01
19:51
Fix a typo in the tests Makefile. check-in: 70f1d07a37 user: js tags: trunk
19:46
Don't call strlen() in -[initWithCString:encoding:length:]. check-in: 16ec7469b8 user: js tags: trunk
18:14
Add .xcodeproj. check-in: 2bb0bb11ed user: js tags: trunk
Changes

Modified src/OFString.m from [2b9f485fcd] to [07267760cd].

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






287
288
289
290
291
292
293







-
-
-
-
-
-







	   length: (size_t)len
{
	Class c;
	size_t i, j;

	self = [super init];

	if (len > strlen(str)) {
		c = isa;
		[super dealloc];
		@throw [OFOutOfRangeException newWithClass: c];
	}

	length = len;

	@try {
		string = [self allocMemoryWithSize: length + 1];
	} @catch (OFException *e) {
		/*
		 * We can't use [super dealloc] on OS X here.