malloc reference pointer free exception

F

fmadelino

Hello,

I hope that some one can explain the following behavior.

......

char *lpDummy = NULL;

TheFunction(&lpDummy);

if (lpDummy) free(lpDummy);

......

In the body of TheFunction memory is allocated for
the pointer lpDummy.

When i try to free it raises an error in debug mode
(Visual C++). The message is "DAMAGE: after Normal block ....."

TIA

Filipe Madelino
 
B

Ben Pfaff

I hope that some one can explain the following behavior.

.....

char *lpDummy = NULL;

TheFunction(&lpDummy);

if (lpDummy) free(lpDummy);

.....

In the body of TheFunction memory is allocated for
the pointer lpDummy.

You should probably show us how memory is allocated in
TheFunction. Most newbies screw this up the first few times.
 
D

Dan Pop

In said:
You should probably show us how memory is allocated in
TheFunction. Most newbies screw this up the first few times.

The actual message seems to suggest a buffer overrun.

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,145
Messages
2,570,824
Members
47,371
Latest member
Brkaa

Latest Threads

Top