diff lib/Test/Nginx/HTTP3.pm @ 1905:f35824e75b66

Tests: fixed reading QUIC streams on Perl < 5.24. The parse_stream() routine has had a missing explicit return if there were no streams received. In Perl < 5.24 this used to return no value, or an empty array in the list context. In modern Perl this returns an empty value, or an array of 1 element, which made the check for last index of the returned array work rather by accident. The fix is to return explicitly and to check the array size in callers instead.
author Sergey Kandaurov <pluknet@nginx.com>
date Tue, 06 Jun 2023 18:50:07 +0400
parents 8303f3633f65
children 1baf5fe1d86c
line wrap: on
line diff
--- a/lib/Test/Nginx/HTTP3.pm
+++ b/lib/Test/Nginx/HTTP3.pm
@@ -1947,7 +1947,7 @@ sub read_stream_message {
 
 	while (1) {
 		@data = $self->parse_stream();
-		return @data if $#data;
+		return @data if @data;
 		return if scalar @{$self->{frames_in}};
 
 again:
@@ -1973,7 +1973,7 @@ again:
 			goto retry if $self->{token};
 			$self->handle_frames(parse_frames($plaintext), $level);
 			@data = $self->parse_stream();
-			return @data if $#data;
+			return @data if @data;
 			return if scalar @{$self->{frames_in}};
 		}
 	}
@@ -2005,6 +2005,7 @@ sub parse_stream {
 
 		return ($i, $data, $stream->{eof} ? 1 : 0);
 	}
+	return;
 }
 
 ###############################################################################