Linux-Sparse Archive on
 help / color / Atom feed
* [PATCH] fix stream_prev() for invalid (negative) stream
@ 2020-07-29 22:01 Luc Van Oostenryck
  0 siblings, 0 replies; only message in thread
From: Luc Van Oostenryck @ 2020-07-29 22:01 UTC (permalink / raw)
  To: linux-sparse; +Cc: Luc Van Oostenryck

Now that the parent stream is stored as a position, the validity
of a stream can't anymore be tested by checking if its number
is non-negative because inside a struct position stream number
are stored as an unsigned (and changing it to signed would halve
the maximum number of stream).

So, add a check against input_stream_nr before returning the
previous stream.

Fixes: 4c6cbe557c48205f9b3d2aae4c166cd66446b240
Signed-off-by: Luc Van Oostenryck <>
 tokenize.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tokenize.c b/tokenize.c
index d68fbcd8eebd..ca842f52882b 100644
--- a/tokenize.c
+++ b/tokenize.c
@@ -66,7 +66,10 @@ int stream_prev(int stream)
 	if (stream < 0 || stream > input_stream_nr)
 		return -1;
-	return input_streams[stream];
+	stream = input_streams[stream];
+	if (stream > input_stream_nr)
+		return -1;
+	return stream;
 static struct position stream_pos(stream_t *stream)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-29 22:01 [PATCH] fix stream_prev() for invalid (negative) stream Luc Van Oostenryck

Linux-Sparse Archive on

Archives are clonable:
	git clone --mirror linux-sparse/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-sparse linux-sparse/ \
	public-inbox-index linux-sparse

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone