Fix MojoDuplicateBufferHandle failure behavior
If handle duplication fails due to handle exhaustion we would
incorrectly close the source handle's dispatcher rather than
the newly allocated dispatcher. That's no good, and this does the
right thing instead.
In practice it's unlikely that an instance of Chrome has ever
actually run out of Mojo handles (and many other things would
break as a result in that case anyway), so this is merely fixing
a hypothetical bug.
Bug: 776293
Change-Id: I4872d10b7261721d6f99836ec95c80d4ed385d77
Reviewed-on: https://chromium-review.googlesource.com/733851
Reviewed-by: Jay Civelli <jcivelli@chromium.org>
Commit-Queue: Ken Rockot <rockot@chromium.org>
Cr-Commit-Position: refs/heads/master@{#510876}
CrOS-Libchrome-Original-Commit: 027bc13a7481ee005d535e7fcd433990a0924343
diff --git a/mojo/edk/system/core.cc b/mojo/edk/system/core.cc
index c40601c..d96cf4b 100644
--- a/mojo/edk/system/core.cc
+++ b/mojo/edk/system/core.cc
@@ -968,7 +968,7 @@
*new_buffer_handle = AddDispatcher(new_dispatcher);
if (*new_buffer_handle == MOJO_HANDLE_INVALID) {
LOG(ERROR) << "Handle table full";
- dispatcher->Close();
+ new_dispatcher->Close();
return MOJO_RESULT_RESOURCE_EXHAUSTED;
}