Backed out changeset 51994c27948c (bug 1197280) for test_eme_non_mse_fails.html failures CLOSED TREE

This commit is contained in:
Wes Kocher 2015-09-16 14:39:03 -07:00
parent 082ef20b76
commit 495adce8fa

View File

@ -17,7 +17,6 @@
#include <stdlib.h>
#include <string.h>
#include <mozilla/CheckedInt.h>
#include <utils/SharedBuffer.h>
#include <utils/Atomic.h>
@ -27,13 +26,7 @@ namespace stagefright {
SharedBuffer* SharedBuffer::alloc(size_t size)
{
mozilla::CheckedInt<size_t> allocSize = size;
allocSize += sizeof(SharedBuffer);
if (!allocSize.isValid() || allocSize.value() >= SIZE_MAX) {
return nullptr;
}
SharedBuffer* sb = static_cast<SharedBuffer*>(malloc(allocSize.value()));
SharedBuffer* sb = static_cast<SharedBuffer *>(malloc(sizeof(SharedBuffer) + size));
if (sb) {
sb->mRefs = 1;
sb->mSize = size;
@ -67,17 +60,11 @@ SharedBuffer* SharedBuffer::editResize(size_t newSize) const
if (onlyOwner()) {
SharedBuffer* buf = const_cast<SharedBuffer*>(this);
if (buf->mSize == newSize) return buf;
mozilla::CheckedInt<size_t> reallocSize = newSize;
reallocSize += sizeof(SharedBuffer);
if (reallocSize.isValid() && reallocSize.value() < SIZE_MAX) {
buf = (SharedBuffer*)realloc(buf, reallocSize.value());
if (buf != nullptr) {
buf->mSize = reallocSize.value();
buf = (SharedBuffer*)realloc(buf, sizeof(SharedBuffer) + newSize);
if (buf != NULL) {
buf->mSize = newSize;
return buf;
}
}
// Overflow or allocation failed.
return nullptr;
}
SharedBuffer* sb = alloc(newSize);
if (sb) {