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.