ObjFW  Check-in [f7faf2bfa6]

Overview
Comment:OFInflateStream: Return if we can't read

Otherwise we spin forever if the underlying stream keeps returning 0 on
read.

This can happen if the end of a ZIP part has been reached. Returning
allows to switch the underlying stream to the next part.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | 1.0
Files: files | file ages | folders
SHA3-256: f7faf2bfa6ab019763f102fda5e7540607988f20158d54c48e1bf8948aa33146
User & Date: js on 2024-03-10 23:00:54
Other Links: branch diff | manifest | tags
Context
2024-03-10
23:07
OFZIPArchive: Undo incorrect disk 0 vs 1 fix check-in: fe62007081 user: js tags: 1.0
23:00
OFInflateStream: Return if we can't read check-in: f7faf2bfa6 user: js tags: 1.0
23:00
OFInflateStream: Return if we can't read check-in: a72f602c2a user: js tags: trunk
21:30
OFZIPArchive: More fixes for disk number 0 vs 1 check-in: 2214e91661 user: js tags: 1.0
Changes

Modified src/OFInflateStream.m from [7726e7ab7e] to [533f2c6519].

323
324
325
326
327
328
329



330
331
332
333
334
335
336
			return bytesWritten;

		tmp = (length < (size_t)CTX.length - CTX.position
		    ? (uint16_t)length : CTX.length - CTX.position);

		tmp = (uint16_t)[_stream readIntoBuffer: buffer + bytesWritten
						 length: tmp];




		slidingWindow = _slidingWindow;
		slidingWindowIndex = _slidingWindowIndex;
		for (uint_fast16_t i = 0; i < tmp; i++) {
			slidingWindow[slidingWindowIndex] =
			    buffer[bytesWritten + i];
			slidingWindowIndex = (slidingWindowIndex + 1) &







>
>
>







323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
			return bytesWritten;

		tmp = (length < (size_t)CTX.length - CTX.position
		    ? (uint16_t)length : CTX.length - CTX.position);

		tmp = (uint16_t)[_stream readIntoBuffer: buffer + bytesWritten
						 length: tmp];

		if OF_UNLIKELY (tmp == 0)
			return bytesWritten;

		slidingWindow = _slidingWindow;
		slidingWindowIndex = _slidingWindowIndex;
		for (uint_fast16_t i = 0; i < tmp; i++) {
			slidingWindow[slidingWindowIndex] =
			    buffer[bytesWritten + i];
			slidingWindowIndex = (slidingWindowIndex + 1) &