From: Jack on
Hi Igor,
Thanks for your help first!
I've posted the whole method under Jochen's post :)
Could you please cross-check the coding for me?
Under jochen's post...
Thanks
Jack


From: Igor Tandetnik on
Jack wrote:
> I've posted the whole method under Jochen's post :)
> Could you please cross-check the coding for me?

It has the exact same problem. Plus the fact that you are no longer doing "new" (delegating to vector to perform the allocation), but are still doing "delete" (on the pointer that you didn't allocate).
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
From: Jack on
Hello Igor,
I hv deleted the "delete binfile" line,but still
buffer overrun
Thanks
Jack



From: Igor Tandetnik on
Jack wrote:
> I hv deleted the "delete binfile" line,but still
> buffer overrun

Because you are still writing past the end of allocated buffer.

std::vector< BYTE > v( size.QuadPart+0x1e0-4 );
memset (binfile, 0, size.QuadPart+0x1e4-4);

Note 0x1e0 in the first line, 0x1e4 in the second.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not necessarily a good idea. It is hard to be sure where they are going to land, and it could be dangerous sitting under them as they fly overhead. -- RFC 1925
From: Stephen Howe on

>> Actually, I have tried both delete and delete[], but doesn't work either.
>
>In this special case (POD) it makes no difference...

Oh yes it does. POD'ness does not come into it. Yes I know there is no destructors

delete [] retrieves the number of items
delete does not.

It is perfectly possible, depending on implementation, that this screws up the heap.
The number of items has been implemented by overallocation of memory blocks but it has also been implemented by associative
arrays. Using delete could cause some non-cleanup of bookkeeping for delete [].

Stephen Howe
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6
Prev: Function vs Method
Next: C-type casting