Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1542)

Unified Diff: mojo/edk/js/core.cc

Issue 2358513002: [mojo] Initialize MojoCreateSharedBufferOptions struct size. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/edk/js/core.cc
diff --git a/mojo/edk/js/core.cc b/mojo/edk/js/core.cc
index 46cfab6342afc78674fc9a93ed34b29636f00e37..f3eec8cc8422ddf69ef0ba5f093a004e3b1d1d06 100644
--- a/mojo/edk/js/core.cc
+++ b/mojo/edk/js/core.cc
@@ -295,6 +295,11 @@ gin::Dictionary CreateSharedBuffer(const gin::Arguments& args,
gin::Dictionary dictionary = gin::Dictionary::CreateEmpty(args.isolate());
MojoHandle handle = MOJO_HANDLE_INVALID;
MojoCreateSharedBufferOptions options;
+ // The |flags| is mandatory parameter for CreateSharedBuffer, and it will
+ // be always initialized in MojoCreateSharedBufferOptions struct. For
+ // forward compatibility, set struct_size to be 8 bytes (struct_size + flags),
+ // so that validator will only check the field that is set.
+ options.struct_size = 8;
options.flags = flags;
MojoResult result = MojoCreateSharedBuffer(&options, num_bytes, &handle);
if (result != MOJO_RESULT_OK) {
@@ -316,11 +321,10 @@ gin::Dictionary DuplicateBufferHandle(
MojoHandle duped = MOJO_HANDLE_INVALID;
MojoDuplicateBufferHandleOptions options;
// The |flags| is mandatory parameter for DuplicateBufferHandle, and it will
- // be always initialized in MojoDuplicateBufferHandleOptions struct. For now,
- // since the struct has only one options field (flags), set struct_size to be
- // equal to the size of MojoDuplicateBufferHandleOptions.
- options.struct_size =
- static_cast<uint32_t>(sizeof(MojoDuplicateBufferHandleOptions));
+ // be always initialized in MojoDuplicateBufferHandleOptions struct. For
+ // forward compatibility, set struct_size to be 8 bytes (struct_size + flags),
+ // so that validator will only check the field that is set.
+ options.struct_size = 8;
options.flags = flags;
MojoResult result =
MojoDuplicateBufferHandle(handle.value(), &options, &duped);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698