ObjFW  Check-in [01fb5e6be3]

Overview
Comment:OFDataArray: Fix double release on error in init
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 01fb5e6be3aca28f35176985e29102c7cd2a4a523d19d06563ded6826273f693
User & Date: js on 2014-02-10 19:13:43
Other Links: manifest | tags
Context
2014-02-10
19:29
Move OFBigDataArray out to its own files check-in: af7e24f9ab user: js tags: trunk
19:13
OFDataArray: Fix double release on error in init check-in: 01fb5e6be3 user: js tags: trunk
19:10
Add test for OF_JSON_REPRESENTATION_JSON5 check-in: 25b3aaf57c user: js tags: trunk
Changes

Modified src/OFDataArray.m from [d2aadda558] to [d6f7fc5fb8].

128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145

- initWithItemSize: (size_t)itemSize
	  capacity: (size_t)capacity
{
	self = [super init];

	@try {
		if (itemSize == 0) {
			[self release];
			@throw [OFInvalidArgumentException exception];
		}

		_items = [self allocMemoryWithSize: itemSize
					     count: capacity];

		_itemSize = itemSize;
		_capacity = capacity;
	} @catch (id e) {







|
<

<







128
129
130
131
132
133
134
135

136

137
138
139
140
141
142
143

- initWithItemSize: (size_t)itemSize
	  capacity: (size_t)capacity
{
	self = [super init];

	@try {
		if (itemSize == 0)

			@throw [OFInvalidArgumentException exception];


		_items = [self allocMemoryWithSize: itemSize
					     count: capacity];

		_itemSize = itemSize;
		_capacity = capacity;
	} @catch (id e) {
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
	  capacity: (size_t)capacity
{
	self = [super init];

	@try {
		size_t size, lastPageByte;

		if (itemSize == 0) {
			[self release];
			@throw [OFInvalidArgumentException exception];
		}

		if (capacity > SIZE_MAX / itemSize)
			@throw [OFOutOfRangeException exception];

		lastPageByte = [OFSystemInfo pageSize] - 1;
		size = (capacity * itemSize + lastPageByte) & ~lastPageByte;








|
<

<







706
707
708
709
710
711
712
713

714

715
716
717
718
719
720
721
	  capacity: (size_t)capacity
{
	self = [super init];

	@try {
		size_t size, lastPageByte;

		if (itemSize == 0)

			@throw [OFInvalidArgumentException exception];


		if (capacity > SIZE_MAX / itemSize)
			@throw [OFOutOfRangeException exception];

		lastPageByte = [OFSystemInfo pageSize] - 1;
		size = (capacity * itemSize + lastPageByte) & ~lastPageByte;