Commit 2d882407 authored by fbarchard@google.com's avatar fbarchard@google.com

Fix ConvertToI420() to properly delete temporary array when rotating result.…

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
parent 431f5f03
Name: libyuv
URL: http://code.google.com/p/libyuv/
Version: 864
Version: 866
License: BSD
License File: LICENSE
......
......@@ -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
......@@ -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;
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment