From d072f0f4d42207d2ecd50782ea56ff67ad35c0be Mon Sep 17 00:00:00 2001 From: mtdxc Date: Thu, 20 Aug 2026 16:47:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dvp9=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E7=A7=92=E5=BC=80bug=20(#4815)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ext-codec/VP8.h | 6 +++++- ext-codec/VP9.h | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/ext-codec/VP8.h b/ext-codec/VP8.h index 10009456..9273c618 100644 --- a/ext-codec/VP8.h +++ b/ext-codec/VP8.h @@ -20,7 +20,11 @@ public: bool keyFrame() const override { auto ptr = (uint8_t *) this->data() + this->prefixSize(); - return !(*ptr & 0x01); + int size = this->size() - this->prefixSize(); + if (size < 10) { + return false; + } + return !(*ptr & 0x01) && ptr[3] == 0x9D && ptr[4] == 0x01 && ptr[5] == 0x2A; } bool configFrame() const override { return false; } bool dropAble() const override { return false; } diff --git a/ext-codec/VP9.h b/ext-codec/VP9.h index c99cd70f..c9d06a89 100644 --- a/ext-codec/VP9.h +++ b/ext-codec/VP9.h @@ -20,7 +20,11 @@ public: bool keyFrame() const override { auto ptr = (uint8_t *) this->data() + this->prefixSize(); - return (*ptr & 0x80); + int size = this->size() - this->prefixSize(); + if (size < 4) { + return false; + } + return (*ptr & 0xCC) == 0x80 && ptr[1] == 0x49 && ptr[2] == 0x83 && ptr[3] == 0x42; } bool configFrame() const override { return false; } bool dropAble() const override { return false; }