Replace a manual buffer allocation with std::vector

To reduce possible memory leaks.

Bug: 128324105
Test: make
Change-Id: I5e1a3d2a0e0b0063878143f4362fd7ff217e337a
Signed-off-by: Roman Kiryanov <rkir@google.com>
diff --git a/system/gralloc/gralloc.cpp b/system/gralloc/gralloc.cpp
index a08873d..851f3b0 100644
--- a/system/gralloc/gralloc.cpp
+++ b/system/gralloc/gralloc.cpp
@@ -45,6 +45,7 @@
 
 #include <set>
 #include <map>
+#include <vector>
 #include <string>
 #include <sstream>
 
@@ -384,11 +385,11 @@
         cb->frameworkFormat != HAL_PIXEL_FORMAT_YV12 &&
         cb->frameworkFormat != HAL_PIXEL_FORMAT_YCbCr_420_888;
 
-    char* convertedBuf = NULL;
+    std::vector<char> convertedBuf;
     if ((doLocked && is_rgb_format) ||
         (!grdma && (doLocked || !is_rgb_format))) {
-        convertedBuf = new char[rgbSz];
-        to_send = convertedBuf;
+        convertedBuf.resize(rgbSz);
+        to_send = convertedBuf.data();
         send_buffer_size = rgbSz;
     }
 
@@ -439,8 +440,6 @@
                 left, top, width, height,
                 cb->glFormat, cb->glType, to_send);
     }
-
-    if (convertedBuf) delete [] convertedBuf;
 }
 
 #ifndef GL_RGBA16F