[eigen] Question regarding QtAllignedMalloc / qRealloc

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]

Dear all,

I just stumbled over the QtAlignedMalloc file and the qRealloc method provided therein. The function is implemented this way:

void *qRealloc(void *ptr, size_t size)
  void* newPtr = Eigen::internal::aligned_malloc(size);
  memcpy(newPtr, ptr, size);
  return newPtr;

My question is: Why can you do the memcpy in that way? If size is larger than the the block pointed to by ptr, memcpy will possibly access invalid memory locations, won't it?

Best regards, Michael

Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/