Changeset 199934 in webkit


Ignore:
Timestamp:
Apr 22, 2016 4:25:54 PM (8 years ago)
Author:
ggaren@apple.com
Message:

bmalloc: Constify introspect function pointer table
https://bugs.webkit.org/show_bug.cgi?id=156936

Reviewed by Michael Saboff.

  • bmalloc/Zone.cpp:

(bmalloc::Zone::Zone): Declaring this function pointer table const puts
it in the read-only section of the binary, providing a little hardening
against overwriting the function pointers at runtime. (We have to
const_cast when assigning because the API declares a pointer to non-const,
but we happen to know it will never try to write through that pointer.
This is not my favorite API.)

Location:
trunk/Source/bmalloc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/bmalloc/ChangeLog

    r199759 r199934  
     12016-04-22  Geoffrey Garen  <ggaren@apple.com>
     2
     3        bmalloc: Constify introspect function pointer table
     4        https://bugs.webkit.org/show_bug.cgi?id=156936
     5
     6        Reviewed by Michael Saboff.
     7
     8        * bmalloc/Zone.cpp:
     9        (bmalloc::Zone::Zone): Declaring this function pointer table const puts
     10        it in the read-only section of the binary, providing a little hardening
     11        against overwriting the function pointers at runtime. (We have to
     12        const_cast when assigning because the API declares a pointer to non-const,
     13        but we happen to know it will never try to write through that pointer.
     14        This is not my favorite API.)
     15
    1162016-04-19  Geoffrey Garen  <ggaren@apple.com>
    217
  • trunk/Source/bmalloc/bmalloc/Zone.cpp

    r198700 r199934  
    105105// constant in the program binary. The leaks process will load this struct
    106106// out of the program binary (and not out of the running process).
    107 static malloc_introspection_t zoneIntrospect = {
     107static const malloc_introspection_t zoneIntrospect = {
    108108    .enumerator = bmalloc::enumerator,
    109109    .good_size = bmalloc::good_size,
     
    120120    malloc_zone_t::size = &bmalloc::zoneSize;
    121121    malloc_zone_t::zone_name = "WebKit Malloc";
    122     malloc_zone_t::introspect = &bmalloc::zoneIntrospect;
     122    malloc_zone_t::introspect = const_cast<malloc_introspection_t*>(&bmalloc::zoneIntrospect);
    123123    malloc_zone_t::version = 4;
    124124    malloc_zone_register(this);
Note: See TracChangeset for help on using the changeset viewer.