ObjFW  Check-in [0eb7274946]

Overview
Comment:Fix too strict OFEnsure introduced in last checkin
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 0eb7274946a6f1dc0544728b586ccac3539a34925b15339e03fea1a62e2007dd
User & Date: js on 2021-11-06 17:00:13
Other Links: manifest | tags
Context
2021-11-06
17:36
Fix OFTLSSocket for the case sockets are not FDs check-in: 746ddd7d7f user: js tags: trunk
17:00
Fix too strict OFEnsure introduced in last checkin check-in: 0eb7274946 user: js tags: trunk
15:57
OFStream: New write API check-in: d1d36ae522 user: js tags: trunk
Changes

Modified src/OFLHAArchive.m from [9340f7479b] to [6f31d26ec9].

480
481
482
483
484
485
486
487
488
489
490
491
492
493
494

	if (UINT32_MAX - _bytesWritten < length)
		@throw [OFOutOfRangeException exception];

	@try {
		[_stream writeBuffer: buffer length: length];
	} @catch (OFWriteFailedException *e) {
		OFEnsure(e.bytesWritten < length);

		_bytesWritten += (uint32_t)e.bytesWritten;
		_CRC16 = OFCRC16(_CRC16, buffer, e.bytesWritten);

		if (e.errNo == EWOULDBLOCK)
			return e.bytesWritten;








|







480
481
482
483
484
485
486
487
488
489
490
491
492
493
494

	if (UINT32_MAX - _bytesWritten < length)
		@throw [OFOutOfRangeException exception];

	@try {
		[_stream writeBuffer: buffer length: length];
	} @catch (OFWriteFailedException *e) {
		OFEnsure(e.bytesWritten <= length);

		_bytesWritten += (uint32_t)e.bytesWritten;
		_CRC16 = OFCRC16(_CRC16, buffer, e.bytesWritten);

		if (e.errNo == EWOULDBLOCK)
			return e.bytesWritten;

Modified src/OFStream.m from [e612790724] to [34c16029c3].

1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085

	if (bytesWritten == _writeBufferLength) {
		OFFreeMemory(_writeBuffer);
		_writeBuffer = NULL;
		_writeBufferLength = 0;
	}

	OFEnsure(bytesWritten < _writeBufferLength);

	memmove(_writeBuffer, _writeBuffer + bytesWritten,
	    _writeBufferLength - bytesWritten);
	_writeBufferLength -= bytesWritten;
	@try {
		_writeBuffer = OFResizeMemory(_writeBuffer,
		    _writeBufferLength, 1);







|







1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085

	if (bytesWritten == _writeBufferLength) {
		OFFreeMemory(_writeBuffer);
		_writeBuffer = NULL;
		_writeBufferLength = 0;
	}

	OFEnsure(bytesWritten <= _writeBufferLength);

	memmove(_writeBuffer, _writeBuffer + bytesWritten,
	    _writeBufferLength - bytesWritten);
	_writeBufferLength -= bytesWritten;
	@try {
		_writeBuffer = OFResizeMemory(_writeBuffer,
		    _writeBufferLength, 1);

Modified src/OFTarArchive.m from [651ec2f405] to [80091b13c1].

436
437
438
439
440
441
442


443
444
445
446
447
448
449

	if ((uint64_t)length > _toWrite)
		@throw [OFOutOfRangeException exception];

	@try {
		[_stream writeBuffer: buffer length: length];
	} @catch (OFWriteFailedException *e) {


		_toWrite -= e.bytesWritten;

		if (e.errNo == EWOULDBLOCK)
			return e.bytesWritten;

		@throw e;
	}







>
>







436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451

	if ((uint64_t)length > _toWrite)
		@throw [OFOutOfRangeException exception];

	@try {
		[_stream writeBuffer: buffer length: length];
	} @catch (OFWriteFailedException *e) {
		OFEnsure(e.bytesWritten <= length);

		_toWrite -= e.bytesWritten;

		if (e.errNo == EWOULDBLOCK)
			return e.bytesWritten;

		@throw e;
	}

Modified src/OFZIPArchive.m from [a5dd4c3dce] to [349c80f1a5].

884
885
886
887
888
889
890
891
892
893
894
895
896
897
898

	if (INT64_MAX - _bytesWritten < (int64_t)length)
		@throw [OFOutOfRangeException exception];

	@try {
		[_stream writeBuffer: buffer length: length];
	} @catch (OFWriteFailedException *e) {
		OFEnsure(e.bytesWritten < length);

		_bytesWritten += (int64_t)e.bytesWritten;
		_CRC32 = OFCRC32(_CRC32, buffer, e.bytesWritten);

		if (e.errNo == EWOULDBLOCK)
			return e.bytesWritten;








|







884
885
886
887
888
889
890
891
892
893
894
895
896
897
898

	if (INT64_MAX - _bytesWritten < (int64_t)length)
		@throw [OFOutOfRangeException exception];

	@try {
		[_stream writeBuffer: buffer length: length];
	} @catch (OFWriteFailedException *e) {
		OFEnsure(e.bytesWritten <= length);

		_bytesWritten += (int64_t)e.bytesWritten;
		_CRC32 = OFCRC32(_CRC32, buffer, e.bytesWritten);

		if (e.errNo == EWOULDBLOCK)
			return e.bytesWritten;