From 8eb59271a520888aa1eaae1eb90e7b8ff81b47c6 Mon Sep 17 00:00:00 2001 From: eladash Date: Mon, 11 Mar 2019 21:31:45 +0200 Subject: [PATCH] Improve error checking of cellVdecOpen Those are the initial argument checks done by the firmware --- rpcs3/Emu/Cell/Modules/cellVdec.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/rpcs3/Emu/Cell/Modules/cellVdec.cpp b/rpcs3/Emu/Cell/Modules/cellVdec.cpp index d9a6866f7c..27ee3651cc 100644 --- a/rpcs3/Emu/Cell/Modules/cellVdec.cpp +++ b/rpcs3/Emu/Cell/Modules/cellVdec.cpp @@ -435,6 +435,17 @@ s32 cellVdecQueryAttrEx(vm::cptr type, vm::ptr att template static s32 vdecOpen(ppu_thread& ppu, T type, U res, vm::cptr cb, vm::ptr handle) { + if (!type || !res || !cb || !handle) + { + return CELL_VDEC_ERROR_ARG; + } + + if (u32(res->ppuThreadPriority) > 3071 || u32(res->spuThreadPriority) > 255 || res->ppuThreadStackSize < 4096 + || u32(type->codecType) > 0xd) + { + return CELL_VDEC_ERROR_ARG; + } + // Create decoder context const u32 vid = idm::make(type->codecType, type->profileLevel, res->memAddr, res->memSize, cb->cbFunc, cb->cbArg);