Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 02b37f75 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix memory leak." into oc-dr1-dev

parents 607b5d1b 4535179b
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
#define ANDROID_PDX_UTILITY_H_

#include <cstdint>
#include <cstdlib>
#include <iterator>

#include <pdx/rpc/sequence.h>
@@ -23,6 +24,7 @@ class ByteBuffer {
    if (other.size())
      memcpy(data_, other.data(), other.size());
  }
  ~ByteBuffer() { std::free(data_); }

  ByteBuffer& operator=(const ByteBuffer& other) {
    resize(other.size());
@@ -69,7 +71,7 @@ class ByteBuffer {
    size |= size >> 8;
    size |= size >> 16;
    size++;
    void* new_data = data_ ? realloc(data_, size) : malloc(size);
    void* new_data = data_ ? std::realloc(data_, size) : std::malloc(size);
    // TODO(avakulenko): Check for allocation failures.
    data_ = static_cast<uint8_t*>(new_data);
    capacity_ = size;