From 17a84989828378bfe5b1ca674b957d8964111036 Mon Sep 17 00:00:00 2001 From: Natasha Lee Date: Tue, 25 Feb 2020 19:20:15 +0000 Subject: [PATCH] ObjectStorage Allocate nullptr when id is 0 Bug: chromium:1052673 Change-Id: I16e39807a48f7a2c937b2a993f3a17cc8f58eac3 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/16161 Commit-Queue: Natasha Lee Reviewed-by: Corentin Wallez --- src/dawn_wire/server/ObjectStorage.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dawn_wire/server/ObjectStorage.h b/src/dawn_wire/server/ObjectStorage.h index 55d6a0962a..e98966dc4e 100644 --- a/src/dawn_wire/server/ObjectStorage.h +++ b/src/dawn_wire/server/ObjectStorage.h @@ -94,10 +94,10 @@ namespace dawn_wire { namespace server { } // Allocates the data for a given ID and returns it. - // Returns nullptr if the ID is already allocated, or too far ahead. - // Invalidates all the Data* + // Returns nullptr if the ID is already allocated, or too far ahead, or if ID is 0 (ID 0 is + // reserved for nullptr). Invalidates all the Data* Data* Allocate(uint32_t id) { - if (id > mKnown.size()) { + if (id == 0 || id > mKnown.size()) { return nullptr; }