[libvpx] scan-build: Fix "Dereference of null pointer" in vp8_peek_si_internal

This commit is contained in:
Andrey Volk 2020-02-16 14:31:13 +04:00
parent 9cf6521873
commit 4b971dff75
1 changed files with 11 additions and 3 deletions

View File

@ -117,11 +117,17 @@ static vpx_codec_err_t vp8_destroy(vpx_codec_alg_priv_t *ctx) {
return VPX_CODEC_OK; return VPX_CODEC_OK;
} }
#ifdef __clang_analyzer__
#define FUNC_ATTR_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
#else
#define FUNC_ATTR_NONNULL(...)
#endif
static vpx_codec_err_t vp8_peek_si_internal(const uint8_t *data, static vpx_codec_err_t vp8_peek_si_internal(const uint8_t *data,
unsigned int data_sz, unsigned int data_sz,
vpx_codec_stream_info_t *si, vpx_codec_stream_info_t *si,
vpx_decrypt_cb decrypt_cb, vpx_decrypt_cb decrypt_cb,
void *decrypt_state) { void *decrypt_state) FUNC_ATTR_NONNULL(1) {
vpx_codec_err_t res = VPX_CODEC_OK; vpx_codec_err_t res = VPX_CODEC_OK;
assert(data != NULL); assert(data != NULL);
@ -267,7 +273,7 @@ static int update_fragments(vpx_codec_alg_priv_t *ctx, const uint8_t *data,
static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t *ctx, static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t *ctx,
const uint8_t *data, unsigned int data_sz, const uint8_t *data, unsigned int data_sz,
void *user_priv, long deadline) { void *user_priv, long deadline) {
volatile vpx_codec_err_t res; volatile vpx_codec_err_t res = VPX_CODEC_INVALID_PARAM;
unsigned int resolution_change = 0; unsigned int resolution_change = 0;
unsigned int w, h; unsigned int w, h;
@ -285,8 +291,10 @@ static vpx_codec_err_t vp8_decode(vpx_codec_alg_priv_t *ctx,
w = ctx->si.w; w = ctx->si.w;
h = ctx->si.h; h = ctx->si.h;
res = vp8_peek_si_internal(ctx->fragments.ptrs[0], ctx->fragments.sizes[0], if (ctx->fragments.ptrs[0]) {
res = vp8_peek_si_internal(ctx->fragments.ptrs[0], ctx->fragments.sizes[0],
&ctx->si, ctx->decrypt_cb, ctx->decrypt_state); &ctx->si, ctx->decrypt_cb, ctx->decrypt_state);
}
if ((res == VPX_CODEC_UNSUP_BITSTREAM) && !ctx->si.is_kf) { if ((res == VPX_CODEC_UNSUP_BITSTREAM) && !ctx->si.is_kf) {
/* the peek function returns an error for non keyframes, however for /* the peek function returns an error for non keyframes, however for