From 2d8824079a1460b8b42faa93753f09ef8375a084 Mon Sep 17 00:00:00 2001 From: "fbarchard@google.com" Date: Wed, 20 Nov 2013 21:18:23 +0000 Subject: [PATCH] Fix ConvertToI420() to properly delete temporary array when rotating result. When rotating an image ConvertToI420() allocates a temporary buffer using new[], but then attempts to delete it using delete instead of delete[].This issue is not the root cause of the referenced bug, but it needs to be addressed in order to fix that bug. BUG=crbug.com/306876 TESTED=try bots R=wuwang@google.com Review URL: https://webrtc-codereview.appspot.com/4129005 git-svn-id: http://libyuv.googlecode.com/svn/trunk@866 16f28f9a-4ce2-e073-06de-1de4eb20be90 --- README.chromium | 2 +- include/libyuv/version.h | 2 +- source/convert_to_argb.cc | 10 +++++----- source/convert_to_i420.cc | 10 +++++----- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.chromium b/README.chromium index ee3a0612b..c9bf97ec0 100644 --- a/README.chromium +++ b/README.chromium @@ -1,6 +1,6 @@ Name: libyuv URL: http://code.google.com/p/libyuv/ -Version: 864 +Version: 866 License: BSD License File: LICENSE diff --git a/include/libyuv/version.h b/include/libyuv/version.h index 1516076d9..55bed01ad 100644 --- a/include/libyuv/version.h +++ b/include/libyuv/version.h @@ -11,6 +11,6 @@ #ifndef INCLUDE_LIBYUV_VERSION_H_ // NOLINT #define INCLUDE_LIBYUV_VERSION_H_ -#define LIBYUV_VERSION 864 +#define LIBYUV_VERSION 866 #endif // INCLUDE_LIBYUV_VERSION_H_ NOLINT diff --git a/source/convert_to_argb.cc b/source/convert_to_argb.cc index 95b6386d7..aa6185661 100644 --- a/source/convert_to_argb.cc +++ b/source/convert_to_argb.cc @@ -61,15 +61,15 @@ int ConvertToARGB(const uint8* sample, size_t sample_size, bool need_buf = (rotation && format != FOURCC_ARGB) || dst_argb == sample; uint8* tmp_argb = dst_argb; int tmp_argb_stride = argb_stride; - uint8* buf = NULL; + uint8* rotate_buffer = NULL; int abs_dst_height = (dst_height < 0) ? -dst_height : dst_height; if (need_buf) { int argb_size = dst_width * abs_dst_height * 4; - buf = new uint8[argb_size]; - if (!buf) { + rotate_buffer = new uint8[argb_size]; + if (!rotate_buffer) { return 1; // Out of memory runtime error. } - dst_argb = buf; + dst_argb = rotate_buffer; argb_stride = dst_width; } @@ -312,7 +312,7 @@ int ConvertToARGB(const uint8* sample, size_t sample_size, tmp_argb, tmp_argb_stride, dst_width, abs_dst_height, rotation); } - delete buf; + delete [] rotate_buffer; } return r; diff --git a/source/convert_to_i420.cc b/source/convert_to_i420.cc index 763eb5092..5683ffe43 100644 --- a/source/convert_to_i420.cc +++ b/source/convert_to_i420.cc @@ -68,16 +68,16 @@ int ConvertToI420(const uint8* sample, int tmp_y_stride = y_stride; int tmp_u_stride = u_stride; int tmp_v_stride = v_stride; - uint8* buf = NULL; + uint8* rotate_buffer = NULL; int abs_dst_height = (dst_height < 0) ? -dst_height : dst_height; if (need_buf) { int y_size = dst_width * abs_dst_height; int uv_size = ((dst_width + 1) / 2) * ((abs_dst_height + 1) / 2); - buf = new uint8[y_size + uv_size * 2]; - if (!buf) { + rotate_buffer = new uint8[y_size + uv_size * 2]; + if (!rotate_buffer) { return 1; // Out of memory runtime error. } - y = buf; + y = rotate_buffer; u = y + y_size; v = u + uv_size; y_stride = dst_width; @@ -372,7 +372,7 @@ int ConvertToI420(const uint8* sample, tmp_v, tmp_v_stride, dst_width, abs_dst_height, rotation); } - delete buf; + delete [] rotate_buffer; } return r;