1237848-check-lookahead-ctx.patch 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # HG changeset patch
  2. # User Gerald Squelart <gsquelart@mozilla.com>
  3. # Parent 5f9ba76eb3b1fd9377bbdb4cc2f98a7e75eabdfb
  4. Bug 1237848 - Check lookahead ctx - r=rillian
  5. Copied from https://chromium-review.googlesource.com/324510
  6. diff --git a/media/libvpx/vp8/encoder/lookahead.c b/media/libvpx/vp8/encoder/lookahead.c
  7. --- a/media/libvpx/vp8/encoder/lookahead.c
  8. +++ b/media/libvpx/vp8/encoder/lookahead.c
  9. @@ -176,16 +176,17 @@ vp8_lookahead_push(struct lookahead_ctx
  10. struct lookahead_entry*
  11. vp8_lookahead_pop(struct lookahead_ctx *ctx,
  12. int drain)
  13. {
  14. struct lookahead_entry* buf = NULL;
  15. + assert(ctx != NULL);
  16. if(ctx->sz && (drain || ctx->sz == ctx->max_sz - 1))
  17. {
  18. buf = pop(ctx, &ctx->read_idx);
  19. ctx->sz--;
  20. }
  21. return buf;
  22. }
  23. diff --git a/media/libvpx/vp9/encoder/vp9_lookahead.c b/media/libvpx/vp9/encoder/vp9_lookahead.c
  24. --- a/media/libvpx/vp9/encoder/vp9_lookahead.c
  25. +++ b/media/libvpx/vp9/encoder/vp9_lookahead.c
  26. @@ -202,17 +202,17 @@ int vp9_lookahead_push(struct lookahead_
  27. return 0;
  28. }
  29. struct lookahead_entry *vp9_lookahead_pop(struct lookahead_ctx *ctx,
  30. int drain) {
  31. struct lookahead_entry *buf = NULL;
  32. - if (ctx->sz && (drain || ctx->sz == ctx->max_sz - MAX_PRE_FRAMES)) {
  33. + if (ctx && ctx->sz && (drain || ctx->sz == ctx->max_sz - MAX_PRE_FRAMES)) {
  34. buf = pop(ctx, &ctx->read_idx);
  35. ctx->sz--;
  36. }
  37. return buf;
  38. }
  39. struct lookahead_entry *vp9_lookahead_peek(struct lookahead_ctx *ctx,