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

Side by Side Diff: ppapi/proxy/video_decoder_resource_unittest.cc

Issue 2593873002: Fix use-after-free issue in VideoDecoderResourceTest. (Closed)
Patch Set: Created 3 years, 12 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 unified diff | Download patch
« 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <GLES2/gl2.h> 5 #include <GLES2/gl2.h>
6 #include <stddef.h> 6 #include <stddef.h>
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 int32_t CallDecode(PP_Resource pp_decoder, 140 int32_t CallDecode(PP_Resource pp_decoder,
141 MockCompletionCallback* cb, 141 MockCompletionCallback* cb,
142 const PpapiHostMsg_VideoDecoder_GetShm* expected_shm_msg) { 142 const PpapiHostMsg_VideoDecoder_GetShm* expected_shm_msg) {
143 // Set up a handler in case the resource sends a sync message to create 143 // Set up a handler in case the resource sends a sync message to create
144 // shared memory. 144 // shared memory.
145 PpapiPluginMsg_VideoDecoder_GetShmReply shm_msg_reply(kShmSize); 145 PpapiPluginMsg_VideoDecoder_GetShmReply shm_msg_reply(kShmSize);
146 ResourceSyncCallHandler shm_msg_handler( 146 ResourceSyncCallHandler shm_msg_handler(
147 &sink(), PpapiHostMsg_VideoDecoder_GetShm::ID, PP_OK, shm_msg_reply); 147 &sink(), PpapiHostMsg_VideoDecoder_GetShm::ID, PP_OK, shm_msg_reply);
148 sink().AddFilter(&shm_msg_handler); 148 sink().AddFilter(&shm_msg_handler);
149 149
150 std::unique_ptr<base::SharedMemoryHandle> shm_handle;
151 std::unique_ptr<SerializedHandle> serialized_handle;
150 base::SharedMemory shm; 152 base::SharedMemory shm;
151 if (expected_shm_msg) { 153 if (expected_shm_msg) {
152 shm.CreateAnonymous(kShmSize); 154 shm.CreateAnonymous(kShmSize);
153 base::SharedMemoryHandle shm_handle; 155 shm_handle.reset(new base::SharedMemoryHandle());
154 shm.ShareToProcess(base::GetCurrentProcessHandle(), &shm_handle); 156 shm.ShareToProcess(base::GetCurrentProcessHandle(), shm_handle.get());
155 SerializedHandle serialized_handle(shm_handle, kShmSize); 157 serialized_handle.reset(new SerializedHandle(*shm_handle, kShmSize));
156 shm_msg_handler.set_serialized_handle(&serialized_handle); 158 shm_msg_handler.set_serialized_handle(serialized_handle.get());
157 } 159 }
158 160
159 memset(decode_buffer_, 0x55, kDecodeBufferSize); 161 memset(decode_buffer_, 0x55, kDecodeBufferSize);
160 int32_t result = 162 int32_t result =
161 decoder_iface()->Decode(pp_decoder, 163 decoder_iface()->Decode(pp_decoder,
162 kDecodeId, 164 kDecodeId,
163 kDecodeBufferSize, 165 kDecodeBufferSize,
164 decode_buffer_, 166 decode_buffer_,
165 PP_MakeOptionalCompletionCallback( 167 PP_MakeOptionalCompletionCallback(
166 &MockCompletionCallback::Callback, cb)); 168 &MockCompletionCallback::Callback, cb));
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 ASSERT_FALSE(uncalled_cb.called()); 584 ASSERT_FALSE(uncalled_cb.called());
583 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallFlush(decoder.get(), &uncalled_cb)); 585 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallFlush(decoder.get(), &uncalled_cb));
584 ASSERT_FALSE(uncalled_cb.called()); 586 ASSERT_FALSE(uncalled_cb.called());
585 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallReset(decoder.get(), &uncalled_cb)); 587 ASSERT_EQ(PP_ERROR_RESOURCE_FAILED, CallReset(decoder.get(), &uncalled_cb));
586 ASSERT_FALSE(uncalled_cb.called()); 588 ASSERT_FALSE(uncalled_cb.called());
587 } 589 }
588 #endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS) 590 #endif // !defined(OS_WIN) || !defined(ARCH_CPU_64_BITS)
589 591
590 } // namespace proxy 592 } // namespace proxy
591 } // namespace ppapi 593 } // namespace ppapi
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