From daa6068d02fd8a68a5f7d23c0f8f1b4166f75fbe Mon Sep 17 00:00:00 2001 From: llyyr Date: Tue, 9 Jul 2024 02:25:54 +0530 Subject: [PATCH] stream_bluray: check fread return value --- stream/stream_bluray.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c index 377ecd3b2b..95a3eec60e 100644 --- a/stream/stream_bluray.c +++ b/stream/stream_bluray.c @@ -551,16 +551,18 @@ static bool check_bdmv(const char *path) if (!temp) return false; - char data[50] = {0}; + char data[50]; + bool ret = false; + + if (fread(data, 50, 1, temp) == 1) { + bstr bdata = {data, 50}; + ret = bstr_startswith0(bdata, "MOBJ0100") || // AVCHD + bstr_startswith0(bdata, "MOBJ0200") || // Blu-ray + bstr_startswith0(bdata, "MOBJ0300"); // UHD BD + } - fread(data, 50, 1, temp); fclose(temp); - - bstr bdata = {data, 50}; - - return bstr_startswith0(bdata, "MOBJ0100") || // AVCHD - bstr_startswith0(bdata, "MOBJ0200") || // Blu-ray - bstr_startswith0(bdata, "MOBJ0300"); // UHD BD + return ret; } // Destructively remove the current trailing path component.