Skip to content

In-depth lesson · Memory corruption

Root causes

Every point the Memory corruption reports back under this heading, best-backed first, each with the reports it is seen in.

Back to the lesson 2,651 to 2,700 of 3,817
  1. The code assumed the device stop call always fenced the IO thread, but on failure it did not and there was no fallback lock.

    Seen in 1 report
  2. The code assumed the finished source handler list was always a subset of the active list, but clearing the active list left dangling entries in the finished list.

    Seen in 1 report
  3. The code assumes a certain multipart event always occurs before the end event, so it uses an uninitialised pointer when that event is skipped.

    Seen in 1 report
  4. The code assumes a deprecated map stays a fast map, but the update can turn it into a dictionary map, causing type confusion when writing the property.

    Seen in 1 report
  5. The code assumes a non-null return from window creation means the new contents are alive, but singleton tab navigation destroys them while a pre-existing tab pointer is returned.

    Seen in 1 report
  6. The code assumes a shared assigned slot means the parent is that slot, but after range mutation it can be the ordinary shadow host.

    Seen in 1 report
  7. The code assumes a variable-length mask is always large enough.

    Seen in 1 report
  8. The code assumes the ':' separator comes before the '@' separator, so when the order is reversed, the calculated length becomes negative and wraps to a huge value.

    Seen in 1 report
  9. The code assumes the AEAD operation runs in place and treats the TX and RX scatter-gather lists as one shared buffer when they are separate mappings.

    Seen in 1 report
  10. The code assumes the bit plane count matches the colour depth used to size the palette, which fails for values other than 24 or below 8.

    Seen in 1 report
  11. The code assumes the buffer size is at least the alignment offset, but a smaller size causes an out-of-bounds write and unsigned integer underflow.

    Seen in 1 report
  12. The code builds an HTTP request into a fixed 200-byte buffer without checking the length of the control URL components.

    Seen in 1 report
  13. The code cached a this pointer before a blocking call that spins a nested event loop, so the object could be destroyed and then used.

    Seen in 1 report
  14. The code calculates the length of the pixel data buffer using the overlay dimensions instead of the actual data length, causing the end pointer to exceed the buffer bounds.

    Seen in 1 report
  15. The code called exit fullscreen, which could spin a nested message loop, and then continued to use the this pointer without checking whether the object had been destroyed.

    Seen in 1 report
  16. The code called out to a delegate without checking whether the animation sequence still existed afterwards.

    Seen in 1 report
  17. The code calls functions that can run JavaScript synchronously and destroy the object without checking it still exists afterwards.

    Seen in 1 report
  18. The code calls gesture dispatch synchronously and then dereferences its own object without checking it is still alive.

    Seen in 1 report
  19. The code calls pthread_cancel without pthread_join, so threads scheduled for cancellation may still run and access freed resources.

    Seen in 1 report
  20. The code calls realloc on the receive buffer but does not update or invalidate pointers derived from the old buffer before the resize.

    Seen in 1 report
  21. The code checked the input length was at least the allocation size but then copied the whole input length into a buffer sized only for the unpadded frame.

    Seen in 1 report
  22. The code compares a hexadecimal length against a raw byte length, allowing the decrypted length to be twice the buffer size.

    Seen in 1 report
  23. The code copies a fixed error string with strcpy and only checks the destination size via a DEBUGASSERT that is removed in release builds.

    Seen in 1 report
  24. The code copies the minimum of string length and buffer size, then uses that value as an index to write a null terminator one past the end.

    Seen in 1 report
  25. The code copies user-supplied Duration XML data into a fixed-length stack buffer without checking its length.

    Seen in 1 report
  26. The code did not check that a palette object still existed before using it, so a freed object could be accessed.

    Seen in 1 report
  27. The code did not check that the number of elements written to the field length array stayed within its size, and an integer overflow bypassed the length limit.

    Seen in 1 report
  28. The code did not check that the number of lock TLVs stayed within the maximum before writing to the array.

    Seen in 1 report
  29. The code did not check whether the object was still alive after a nested modal message loop returned, leading to a write to freed memory.

    Seen in 1 report
  30. The code did not hold a reference to a number input's anonymous content while calling select(), letting cycle collection free it.

    Seen in 1 report
  31. The code does not check that a font entry object still exists before using it.

    Seen in 1 report
  32. The code does not check that row and column indices from the file are within the bounds of the allocated cell array before writing.

    Seen in 1 report
  33. The code does not check whether the payment request was destroyed during the synchronous error message call.

    Seen in 1 report
  34. The code does not check whether the read pointer passed the end of the buffer, so a negative remainder becomes a huge copy size.

    Seen in 1 report
  35. The code does not re-check the object's weak pointer after a call that can destroy the controller.

    Seen in 1 report
  36. The code does not verify that the number of tokens read from the file matches the actual number of null-terminated strings in the decompressed buffer, so it continues reading past the buffer end.

    Seen in 1 report
  37. The code fails to check the return value of stream reads, so on failure it uses uninitialised or freed memory.

    Seen in 1 report
  38. The code fires a synchronous accessibility event and then keeps using the view without checking whether it is still alive.

    Seen in 1 report
  39. The code frees 'buf->data' on the error path after Curl_saferealloc() fails, but that pointer was already freed or not updated, leading to a double-free.

    Seen in 1 report
  40. The code hardcodes four bytes per pixel instead of using the actual format's bytes per pixel when computing the readback buffer size.

    Seen in 1 report
  41. The code held an iterator into a flat map across a call that could synchronously re-enter and reallocate the map.

    Seen in 1 report
  42. The code holds a reference into a map across a call that can re-enter JavaScript and clear the map.

    Seen in 1 report
  43. The code increments a technology list count and writes entries without checking array capacity.

    Seen in 1 report
  44. The code iterated a font feature map through a direct reference without protecting against the map being modified or freed during iteration.

    Seen in 1 report
  45. The code iterated a hash map while allowing synchronous script execution that could modify the map and free the backing store.

    Seen in 1 report
  46. The code iterates a copy of a vector of raw pointers to garbage-collected observers, and a collection during the loop frees them, leaving dangling pointers.

    Seen in 1 report
  47. The code iterates a pending loader vector while a call inside the loop can synchronously push into the same vector, invalidating iterators.

    Seen in 1 report
  48. The code multiplies two 32-bit unsigned integers (height and rowbytes) without checking for overflow, leading to an undersized allocation.

    Seen in 1 report
  49. The code multiplies width and height without checking for integer overflow, so on 32-bit systems the result wraps around to a small value, causing under-allocation.

    Seen in 1 report
  50. The code notifies observers without checking whether the payment request state is still alive after observers synchronously trigger a fullscreen exit.

    Seen in 1 report