From fc27e590c39e3b309683e275541fd9b3164985dc Mon Sep 17 00:00:00 2001 From: dec05eba Date: Fri, 11 Mar 2022 12:41:16 +0100 Subject: Fix youtube streaming for really long videos I dedicate this one to rat --- video_player/src/main.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'video_player/src') diff --git a/video_player/src/main.cpp b/video_player/src/main.cpp index 4ec9278..e166e85 100644 --- a/video_player/src/main.cpp +++ b/video_player/src/main.cpp @@ -449,25 +449,33 @@ static int64_t size_fn(void *cookie) { if(res == 0) { size_t header_start = str_find_case_insensitive(buffer, 0, "200 OK", 6); - if(header_start == std::string::npos) + if(header_start == std::string::npos) { + res = MPV_ERROR_UNSUPPORTED; goto end; + } header_start += 6; size_t content_length_index = str_find_case_insensitive(buffer, header_start, "content-length:", 15); - if(content_length_index == std::string::npos) + if(content_length_index == std::string::npos) { + res = MPV_ERROR_UNSUPPORTED; goto end; + } content_length_index += 15; size_t content_length_end = buffer.find('\r', content_length_index); - if(content_length_end == std::string::npos) + if(content_length_end == std::string::npos) { + res = MPV_ERROR_UNSUPPORTED; goto end; + } buffer[content_length_end] = '\0'; errno = 0; char *endptr; int64_t content_length = strtoll(&buffer[content_length_index], &endptr, 10); - if(endptr == &buffer[content_length_index] || errno != 0) + if(endptr == &buffer[content_length_index] || errno != 0) { + res = MPV_ERROR_UNSUPPORTED; goto end; + } res = content_length; } -- cgit v1.2.3