ObjFW  Check-in [a72f602c2a]

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 | trunk
Files: files | file ages | folders
SHA3-256: a72f602c2a5e89adca97e91a0ae7784fc00240a97d2006c8bb4f562f3bcbcb6a
User & Date: js on 2024-03-10 23:00:24
Other Links: manifest | tags
Context
2024-03-10
23:06
OFZIPArchive: Undo incorrect disk 0 vs 1 fix check-in: 0c8f496588 user: js tags: trunk
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: 0ecd85c8e3 user: js tags: trunk
Changes

Modified src/OFInflateStream.m from [6ae6dfa239] to [9d9894c2fe].

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) &