Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Memory allocation inside DLL returning null pointer

I'm using a DLL which performs some memory allocation and returns a pointer. The code is something like that:

ObjectClass *obj = FunctionFromDLL();

obj is a valid pointer but obj->SubObject is a bad pointer (0xcdcdcd) I checked and FunctionFromDLL() correctly allocates SubObject, this pointer only gets a bad value when function is returning to caller.

Is there something special for the DLL to "share" its memory?

like image 618
Guillaume Avatar asked Feb 09 '26 15:02

Guillaume


1 Answers

There is no special way of sharing memory allocated between dll and app, just make sure to delete memory in dll AFTER you don't use it anymore.

Edit: 0xCDCDCDCD : Used by Microsoft's C++ debugging runtime library to mark uninitialised heap memory

like image 162
cprogrammer Avatar answered Feb 12 '26 14:02

cprogrammer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!