Community
cancel
Showing results for 
Search instead for 
Did you mean: 
jim_cox
Beginner
84 Views

Need help with ASSERTE _CrtIsValidHeapPointer (pUserData)

Jump to solution
Hello All

I'm moving some old msC++ code to Intel

With Intel, the porgram generates an _ASSERTE _CrtIsValidHeapPointer (pUserData) when running



The code in question is calling free(value)

Where value is locally defined as char *value

Presumably this implies that value has been created on the stack



So my questions are

a: should free be being called at all ?

and b: if so is there a compiler setting that will allow the Intel build to run as before?



Thankx for your help

Jim

=mjc=
.

0 Kudos
1 Solution
Dale_S_Intel
Employee
84 Views
Well, unless I'm missing something, the issue is not how value has been declared (as a char *) but what has been assigned to it. If it has been assigned using some sort of malloc(), then it there should be a free() of it, but if it has been assigned some other way, or if free() has already been called on that location somewhere else (possibly in another function) then I would expect it to be problematic. For example, if you said

char *value;
value = "Hello World";

then you would not want to call free(value). But if you said

vaule = (char *)malloc(strlen("Hello World"));

then you should call free(value) at some point.

Is that what you're asking?

Thanks!
Dale

View solution in original post

2 Replies
Dale_S_Intel
Employee
85 Views
Well, unless I'm missing something, the issue is not how value has been declared (as a char *) but what has been assigned to it. If it has been assigned using some sort of malloc(), then it there should be a free() of it, but if it has been assigned some other way, or if free() has already been called on that location somewhere else (possibly in another function) then I would expect it to be problematic. For example, if you said

char *value;
value = "Hello World";

then you would not want to call free(value). But if you said

vaule = (char *)malloc(strlen("Hello World"));

then you should call free(value) at some point.

Is that what you're asking?

Thanks!
Dale

View solution in original post

jim_cox
Beginner
84 Views
Thankx Dale

You have confirmed my suspicions

There is no malloc - therefore the free is bad.

And I suspect this was not being caught by the old compiler

I comment out the statements (there were many of them) and the Assert goes away :)

Thankx again for your help

Cheers

Jim

=mjc=
.
Reply