ObjFW  Check-in [4eb87f934f]

Overview
Comment:Remove multiply overflow check in OFArray - it's done by resizeMem.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 4eb87f934fa29a225533e8585645a0e4fe98f00f3599a65a045ee1745501607e
User & Date: js on 2009-05-03 15:49:04
Other Links: manifest | tags
Context
2009-05-03
17:19
Make OFStream a class instead of a protocol and move readLine there. check-in: 7bf4b144ad user: js tags: trunk
15:49
Remove multiply overflow check in OFArray - it's done by resizeMem. check-in: 4eb87f934f user: js tags: trunk
15:45
readLine: for OFTCPSocket. check-in: dabcc373f7 user: js tags: trunk
Changes

Modified src/OFArray.m from [5aad2dc149] to [09953b1423].

79
80
81
82
83
84
85
86

87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

102
103
104
105
106
107
108
79
80
81
82
83
84
85

86
87
88
89
90
91
92
93
94
95
96
97
98
99
100

101
102
103
104
105
106
107
108







-
+














-
+







- (void*)last
{
	return data + (items - 1) * itemsize;
}

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

	data = [self resizeMem: data
		      toNItems: items + 1
		      withSize: 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)
	if (nitems > SIZE_MAX - items)
		@throw [OFOutOfRangeException newWithClass: isa];

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

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