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

Side by Side Diff: mojo/system/core_impl.cc

Issue 75243005: Mojo: Fix MojoReadMessage() with *num_handles == 0. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/system/core_impl.h" 5 #include "mojo/system/core_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "mojo/system/dispatcher.h" 10 #include "mojo/system/dispatcher.h"
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
315 315
316 if (num_handles) { 316 if (num_handles) {
317 if (!VerifyUserPointer<uint32_t>(num_handles, 1)) 317 if (!VerifyUserPointer<uint32_t>(num_handles, 1))
318 return MOJO_RESULT_INVALID_ARGUMENT; 318 return MOJO_RESULT_INVALID_ARGUMENT;
319 if (!VerifyUserPointer<MojoHandle>(handles, *num_handles)) 319 if (!VerifyUserPointer<MojoHandle>(handles, *num_handles))
320 return MOJO_RESULT_INVALID_ARGUMENT; 320 return MOJO_RESULT_INVALID_ARGUMENT;
321 } 321 }
322 322
323 // Easy case: won't receive any handles. 323 // Easy case: won't receive any handles.
324 if (!num_handles || *num_handles == 0) 324 if (!num_handles || *num_handles == 0)
325 return dispatcher->ReadMessage(bytes, num_bytes, 0, NULL, flags); 325 return dispatcher->ReadMessage(bytes, num_bytes, NULL, num_handles, flags);
326 326
327 std::vector<scoped_refptr<Dispatcher> > dispatchers; 327 std::vector<scoped_refptr<Dispatcher> > dispatchers;
328 MojoResult rv = dispatcher->ReadMessage(bytes, num_bytes, 328 MojoResult rv = dispatcher->ReadMessage(bytes, num_bytes,
329 &dispatchers, num_handles, 329 &dispatchers, num_handles,
330 flags); 330 flags);
331 if (!dispatchers.empty()) { 331 if (!dispatchers.empty()) {
332 DCHECK_EQ(rv, MOJO_RESULT_OK); 332 DCHECK_EQ(rv, MOJO_RESULT_OK);
333 DCHECK(num_handles); 333 DCHECK(num_handles);
334 DCHECK_LE(dispatchers.size(), static_cast<size_t>(*num_handles)); 334 DCHECK_LE(dispatchers.size(), static_cast<size_t>(*num_handles));
335 335
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 // |Wait()|/|WaitMany()| call. (Only after doing this can |waiter| be 437 // |Wait()|/|WaitMany()| call. (Only after doing this can |waiter| be
438 // destroyed, but this would still be required if the waiter were in TLS.) 438 // destroyed, but this would still be required if the waiter were in TLS.)
439 for (i = 0; i < num_added; i++) 439 for (i = 0; i < num_added; i++)
440 dispatchers[i]->RemoveWaiter(&waiter); 440 dispatchers[i]->RemoveWaiter(&waiter);
441 441
442 return rv; 442 return rv;
443 } 443 }
444 444
445 } // namespace system 445 } // namespace system
446 } // namespace mojo 446 } // namespace mojo
OLDNEW
« 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