Changeset 179707 in webkit


Ignore:
Timestamp:
Feb 5, 2015 2:13:10 PM (9 years ago)
Author:
Chris Dumez
Message:

[WK2] Properly check for mmap() error case
https://bugs.webkit.org/show_bug.cgi?id=141304

Reviewed by Anders Carlsson.

mmap() returns MAP_FAILED, which is (void*)-1, not a null pointer in
case of failure. This patch updates several wrong error checks in
WebKit2.

  • Platform/IPC/ArgumentEncoder.cpp:

(IPC::allocBuffer):
(IPC::ArgumentEncoder::reserve):

  • Platform/IPC/mac/ConnectionMac.mm:

(IPC::Connection::sendOutgoingMessage):

Location:
trunk/Source/WebKit2
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r179705 r179707  
     12015-02-05  Chris Dumez  <cdumez@apple.com>
     2
     3        [WK2] Properly check for mmap() error case
     4        https://bugs.webkit.org/show_bug.cgi?id=141304
     5
     6        Reviewed by Anders Carlsson.
     7
     8        mmap() returns MAP_FAILED, which is (void*)-1, not a null pointer in
     9        case of failure. This patch updates several wrong error checks in
     10        WebKit2.
     11
     12        * Platform/IPC/ArgumentEncoder.cpp:
     13        (IPC::allocBuffer):
     14        (IPC::ArgumentEncoder::reserve):
     15        * Platform/IPC/mac/ConnectionMac.mm:
     16        (IPC::Connection::sendOutgoingMessage):
     17
    1182015-02-05  Brian J. Burg  <burg@cs.washington.edu>
    219
  • trunk/Source/WebKit2/Platform/IPC/ArgumentEncoder.cpp

    r176762 r179707  
    3737namespace IPC {
    3838
    39 static inline void* allocBuffer(size_t size)
     39template <typename T>
     40static inline bool allocBuffer(T*& buffer, size_t size)
    4041{
    4142#if OS(DARWIN)
    42     return mmap(0, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
     43    buffer = static_cast<T*>(mmap(0, size, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0));
     44    return buffer != MAP_FAILED;
    4345#else
    44     return fastMalloc(size);
     46    buffer = static_cast<T*>(fastMalloc(size));
     47    return !!buffer;
    4548#endif
    4649}
     
    9194        newCapacity *= 2;
    9295
    93     uint8_t* newBuffer = static_cast<uint8_t*>(allocBuffer(newCapacity));
    94     if (!newBuffer)
     96    uint8_t* newBuffer;
     97    if (!allocBuffer(newBuffer, newCapacity))
    9598        CRASH();
    9699
  • trunk/Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm

    r179373 r179707  
    284284    char stackBuffer[inlineMessageMaxSize];
    285285    char* buffer = &stackBuffer[0];
    286     if (messageSize > inlineMessageMaxSize)
     286    if (messageSize > inlineMessageMaxSize) {
    287287        buffer = (char*)mmap(0, messageSize, PROT_READ | PROT_WRITE, MAP_ANON | MAP_PRIVATE, -1, 0);
     288        if (buffer == MAP_FAILED)
     289            return false;
     290    }
    288291
    289292    bool isComplex = (numberOfPortDescriptors + numberOfOOLMemoryDescriptors > 0);
Note: See TracChangeset for help on using the changeset viewer.