Changeset 258620 in webkit


Ignore:
Timestamp:
Mar 17, 2020 8:32:31 PM (4 years ago)
Author:
ddkilzer@apple.com
Message:

SharedMemory::Handle::m_size should be more consistent
<https://webkit.org/b/209007>
<rdar://problem/60340890>

Reviewed by Darin Adler.

  • Platform/cocoa/SharedMemoryCocoa.cpp:

(WebKit::SharedMemory::Handle::decode):

  • Return early if an invalid size is decoded.

(WebKit::SharedMemory::map):

  • Drive-by fix to change '0' to 'nullptr'.
  • Since all known methods of creating a SharedMemory::Handle() set SharedMemory::Handle::m_size to a value of round_page(), this means we can also change round_page(handle.m_size) to handle.m_size in the call to mach_vm_map() since we know they're equal.
Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r258617 r258620  
     12020-03-17  David Kilzer  <ddkilzer@apple.com>
     2
     3        SharedMemory::Handle::m_size should be more consistent
     4        <https://webkit.org/b/209007>
     5        <rdar://problem/60340890>
     6
     7        Reviewed by Darin Adler.
     8
     9        * Platform/cocoa/SharedMemoryCocoa.cpp:
     10        (WebKit::SharedMemory::Handle::decode):
     11        - Return early if an invalid `size` is decoded.
     12        (WebKit::SharedMemory::map):
     13        - Drive-by fix to change '0' to 'nullptr'.
     14        - Since all known methods of creating a SharedMemory::Handle()
     15          set SharedMemory::Handle::m_size to a value of round_page(),
     16          this means we can also change `round_page(handle.m_size)` to
     17          `handle.m_size` in the call to mach_vm_map() since we know
     18          they're equal.
     19
    1202020-03-17  Commit Queue  <commit-queue@webkit.org>
    221
  • trunk/Source/WebKit/Platform/cocoa/SharedMemoryCocoa.cpp

    r247815 r258620  
    9494    if (!decoder.decode(size))
    9595        return false;
     96    if (size != round_page(size))
     97        return false;
    9698
    9799    IPC::MachPort machPort;
     
    191193{
    192194    if (handle.isNull())
    193         return 0;
    194    
     195        return nullptr;
     196
    195197    ASSERT(round_page(handle.m_size) == handle.m_size);
    196198
    197199    vm_prot_t vmProtection = machProtection(protection);
    198200    mach_vm_address_t mappedAddress = 0;
    199     kern_return_t kr = mach_vm_map(mach_task_self(), &mappedAddress, round_page(handle.m_size), 0, VM_FLAGS_ANYWHERE, handle.m_port, 0, false, vmProtection, vmProtection, VM_INHERIT_NONE);
     201    kern_return_t kr = mach_vm_map(mach_task_self(), &mappedAddress, handle.m_size, 0, VM_FLAGS_ANYWHERE, handle.m_port, 0, false, vmProtection, vmProtection, VM_INHERIT_NONE);
    200202#if RELEASE_LOG_DISABLED
    201203    if (kr != KERN_SUCCESS)
Note: See TracChangeset for help on using the changeset viewer.