Ignore:
Timestamp:
Nov 11, 2007, 7:36:03 PM (18 years ago)
Author:
oliver
Message:

Partial fix for <rdar://problem/5585334> numfuzz: integer overflows opening malformed SVG file in WebCore::ImageBuffer::create

Reviewed By Eric.

Unfortunately this is a very slight regression, but is unavoidable.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/FastMalloc.cpp

    r27336 r27698  
    22932293#endif
    22942294void* calloc(size_t n, size_t elem_size) {
    2295   void* result = do_malloc(n * elem_size);
     2295  const size_t totalBytes = n * elem_size;
     2296   
     2297  // Protect against overflow
     2298  if (n > 1 && elem_size && (totalBytes / elem_size) != n)
     2299    return 0;
     2300   
     2301  void* result = do_malloc(totalBytes);
    22962302  if (result != NULL) {
    2297     memset(result, 0, n * elem_size);
    2298   }
    2299 #ifndef WTF_CHANGES
    2300   MallocHook::InvokeNewHook(result, n * elem_size);
     2303    memset(result, 0, totalBytes);
     2304  }
     2305#ifndef WTF_CHANGES
     2306  MallocHook::InvokeNewHook(result, totalBytes);
    23012307#endif
    23022308  return result;
Note: See TracChangeset for help on using the changeset viewer.