Changeset 272744 in webkit


Ignore:
Timestamp:
Feb 11, 2021, 1:30:31 PM (5 years ago)
Author:
Darin Adler
Message:

[Cocoa] IPC decoder is using decoded size to allocate memory for an array
https://bugs.webkit.org/show_bug.cgi?id=221773

Reviewed by Geoffrey Garen.

  • Shared/Cocoa/ArgumentCodersCocoa.mm:

(IPC::decodeArrayInternal): As with other similar structures, such a Vector and
CFArray, don't use the size to preallocate space when decoding an NSArray. The
decoded size is potentially incorrect, which we will discover indirectly when
decoding the array elements; we can't safely use the size to make a choice about
allocating memory beforehand.

Location:
trunk/Source/WebKit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r272741 r272744  
     12021-02-11  Darin Adler  <darin@apple.com>
     2
     3        [Cocoa] IPC decoder is using decoded size to allocate memory for an array
     4        https://bugs.webkit.org/show_bug.cgi?id=221773
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        * Shared/Cocoa/ArgumentCodersCocoa.mm:
     9        (IPC::decodeArrayInternal): As with other similar structures, such a Vector and
     10        CFArray, don't use the size to preallocate space when decoding an NSArray. The
     11        decoded size is potentially incorrect, which we will discover indirectly when
     12        decoding the array elements; we can't safely use the size to make a choice about
     13        allocating memory beforehand.
     14
    1152021-02-11  Brent Fulgham  <bfulgham@apple.com>
    216
  • trunk/Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.mm

    r264006 r272744  
    177177        return WTF::nullopt;
    178178
    179     RetainPtr<NSMutableArray> array = adoptNS([[NSMutableArray alloc] initWithCapacity:size]);
     179    auto array = adoptNS([[NSMutableArray alloc] init]);
    180180    for (uint64_t i = 0; i < size; ++i) {
    181181        auto value = decodeObject(decoder, allowedClasses);
Note: See TracChangeset for help on using the changeset viewer.