On 1/29/2019 3:45 AM, Andrei Alexandrescu wrote:
I am talking about this:

int[] a = cast(int[]) alloc.allocate(100 * int.sizeof);
if (alloc.reallocate(a, 200 * int.sizeof)
{
     assert(a.length == 200);
}

Even simpler:

  void func(ref void* p) {
    free(p);                      // frees (1)
    p = malloc(100);              // (2)
  }

  int* p = cast(int*)malloc(16);  // (1)
  func(p);                        // p copied to temp for conversion to void*
  free(p);                        // frees (1) again
                                  // (2) is left dangling

It's a memory corruption issue, with no way to detect it.

Reply via email to