ObjFW  Check-in [f724e6d794]

Overview
Comment:For some reason, proper overflow checks were only in OFBigArray.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: f724e6d79478eadbcb6b9bd87a4f37546961e702c020758f390e7e47d5c235c9
User & Date: js on 2009-01-07 20:49:35
Other Links: manifest | tags
Context
2009-01-10
03:28
Fix missing deletion of libobjfw.dll. check-in: 635bbd6db8 user: js tags: trunk
2009-01-07
20:49
For some reason, proper overflow checks were only in OFBigArray. check-in: f724e6d794 user: js tags: trunk
17:10
Also release the pools when we release the pool list.
We need to do that manually as we disabled retain / release for the
list.
check-in: 03618ea87b user: js tags: trunk
Changes

Modified src/OFArray.m from [e903248725] to [5b2194bc15].

66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
- (void*)last
{
	return data + (items - 1) * itemsize;
}

- add: (void*)item
{
	if (SIZE_MAX - items < 1)
		@throw [OFOutOfRangeException newWithClass: [self class]];

	data = [self resizeMem: data
		      toNItems: items + 1
			ofSize: itemsize];

	memcpy(data + items++ * itemsize, item, itemsize);

	return self;
}

- addNItems: (size_t)nitems
 fromCArray: (void*)carray
{
	if (nitems > SIZE_MAX - items)
		@throw [OFOutOfRangeException newWithClass: [self class]];

	data = [self resizeMem: data
		      toNItems: items + nitems
			ofSize: itemsize];

	memcpy(data + items * itemsize, carray, nitems * itemsize);







|














|







66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
- (void*)last
{
	return data + (items - 1) * itemsize;
}

- add: (void*)item
{
	if (SIZE_MAX - items < 1 || items + 1 > SIZE_MAX / itemsize)
		@throw [OFOutOfRangeException newWithClass: [self class]];

	data = [self resizeMem: data
		      toNItems: items + 1
			ofSize: itemsize];

	memcpy(data + items++ * itemsize, item, itemsize);

	return self;
}

- addNItems: (size_t)nitems
 fromCArray: (void*)carray
{
	if (nitems > SIZE_MAX - items || items + nitems > SIZE_MAX / itemsize)
		@throw [OFOutOfRangeException newWithClass: [self class]];

	data = [self resizeMem: data
		      toNItems: items + nitems
			ofSize: itemsize];

	memcpy(data + items * itemsize, carray, nitems * itemsize);