From ecbd787e4ac4d5ade102cb3b91fee36ea9bbec2c Mon Sep 17 00:00:00 2001 From: Aryan Salmanpour Date: Wed, 8 Nov 2023 10:18:17 -0500 Subject: [PATCH] Add nullptr check for parser APIs before dereferencing the parser's handle (#44) --- src/parser/rocparser_api.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/parser/rocparser_api.cpp b/src/parser/rocparser_api.cpp index 1b088ed758..f4933d063c 100644 --- a/src/parser/rocparser_api.cpp +++ b/src/parser/rocparser_api.cpp @@ -53,6 +53,9 @@ rocDecCreateVideoParser(RocdecVideoParser *pHandle, RocdecParserParams *pParams) /************************************************************************************************/ rocDecStatus ROCDECAPI rocDecParseVideoData(RocdecVideoParser handle, RocdecSourceDataPacket *pPacket) { + if (handle == nullptr) { + return ROCDEC_INVALID_PARAMETER; + } auto parser_hdl = static_cast (handle); rocDecStatus ret; try { @@ -73,6 +76,9 @@ rocDecParseVideoData(RocdecVideoParser handle, RocdecSourceDataPacket *pPacket) /************************************************************************************************/ extern rocDecStatus ROCDECAPI rocDecDestroyVideoParser(RocdecVideoParser handle) { + if (handle == nullptr) { + return ROCDEC_INVALID_PARAMETER; + } auto parser_hdl = static_cast (handle); rocDecStatus ret; try {