"Rakesh" <[EMAIL PROTECTED]> writes:

[Inapproptiate newsgroups trimmed]

> What is wrong this implementation?

Not much. A better question is: what's wrong with your code?

>   for (Iter1 = AddedPhrases.begin(); Iter1 != AddedPhrases.end(); Iter1++)
>   {
>          temp = *Iter1;
>          free(temp);
>   }

You are invalidating the storage of a container that you are
iterating over, but iteration *needs* access to that storage.

This (naturally) results in reading dangling memory (run your program
under valgrind to see how exactly that read dangling happens).

> Deleting:apple:5
> Deleting:absent:6
> *** glibc detected *** ./a.out: double free or corruption (!prev):

But I fail to see how this could result in a double-free, or in
heap corruption.

Regardless, you must fix your code (e.g. by using strings instead of
'char*' pointers).

Cheers,
-- 
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to