Bug 1272203 (part 3) - Use NotNull in nsContentUtils::GetSurfaceData(). r=froydnj.

This might not look compelling in isolation, but this use of NotNull would have
prevented the null dereference crash in bug 1268721.
This commit is contained in:
Nicholas Nethercote
2016-05-27 09:49:25 +10:00
parent e8a80242c9
commit a70a13fd62
4 changed files with 12 additions and 7 deletions

View File

@@ -7424,7 +7424,8 @@ nsContentUtils::TransferableToIPCTransferable(nsITransferable* aTransferable,
size_t length;
int32_t stride;
mozilla::UniquePtr<char[]> surfaceData =
nsContentUtils::GetSurfaceData(dataSurface, &length, &stride);
nsContentUtils::GetSurfaceData(WrapNotNull(dataSurface), &length,
&stride);
IPCDataTransferItem* item = aIPCDataTransfer->items().AppendElement();
item->flavor() = flavorStr;
@@ -7528,7 +7529,8 @@ nsContentUtils::TransferableToIPCTransferable(nsITransferable* aTransferable,
}
mozilla::UniquePtr<char[]>
nsContentUtils::GetSurfaceData(mozilla::gfx::DataSourceSurface* aSurface,
nsContentUtils::GetSurfaceData(
NotNull<mozilla::gfx::DataSourceSurface*> aSurface,
size_t* aLength, int32_t* aStride)
{
mozilla::gfx::DataSourceSurface::MappedSurface map;

View File

@@ -32,6 +32,7 @@
#include "mozilla/FloatingPoint.h"
#include "mozilla/net/ReferrerPolicy.h"
#include "mozilla/Logging.h"
#include "mozilla/NotNull.h"
#include "nsIContentPolicy.h"
#if defined(XP_WIN)
@@ -2432,7 +2433,8 @@ public:
* Get the pixel data from the given source surface and return it as a buffer.
* The length and stride will be assigned from the surface.
*/
static mozilla::UniquePtr<char[]> GetSurfaceData(mozilla::gfx::DataSourceSurface* aSurface,
static mozilla::UniquePtr<char[]> GetSurfaceData(
mozilla::NotNull<mozilla::gfx::DataSourceSurface*> aSurface,
size_t* aLength, int32_t* aStride);
// Helpers shared by the implementations of nsContentUtils methods and

View File

@@ -990,7 +990,7 @@ PuppetWidget::SetCursor(imgIContainer* aCursor,
size_t length;
int32_t stride;
mozilla::UniquePtr<char[]> surfaceData =
nsContentUtils::GetSurfaceData(dataSurface, &length, &stride);
nsContentUtils::GetSurfaceData(WrapNotNull(dataSurface), &length, &stride);
nsDependentCString cursorData(surfaceData.get(), length);
mozilla::gfx::IntSize size = dataSurface->GetSize();

View File

@@ -55,7 +55,8 @@ nsDragServiceProxy::InvokeDragSessionImpl(nsISupportsArray* aArrayTransferables,
size_t length;
int32_t stride;
mozilla::UniquePtr<char[]> surfaceData =
nsContentUtils::GetSurfaceData(dataSurface, &length, &stride);
nsContentUtils::GetSurfaceData(WrapNotNull(dataSurface), &length,
&stride);
nsDependentCString dragImage(surfaceData.get(), length);
mozilla::Unused <<