Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The noncompliant example produces the following (unexpected) output.

Code Block
memory aligned to 4096 bytes

ptr[0] (0x2b7000000000)  : 0xb43c000 = 12.500000
ptr[1] (0x2b7000000004)   : 0xb43c004 = 25.500000

After realloc():
ptr1[0] (0x2b7000000000)  : 0xb43c000 = 12.500000
ptr1[1] (0x2b7000000008) = 0.000000 : 0xb43c008 = 0.000000

The value at ptr[1] remains the same after realloc()
ptr[1]  : 0xb43c004 = 25.500000

Risk Assessment

Improper alignment could lead to accessing arbitrary memory locations and write into it.

...