Mail Archives: djgpp/1997/08/21/12:00:21
On Thu, 21 Aug 1997 15:56:36 +0100 Chris Croughton <crough45 AT amc DOT de> wrote:
> At a rough guess, 'keyword' is pointing to something which is not
> a string terminated by a zero byte. Although your constructor
> tests for 'keyword' not being a null pointer, it does't test that
> it points to real memory (nor can it in a portable way).
>
> Try running it under gdb or another debugger, and get a backtrace
> (stack dump) to see what the value of 'keyword' is being passed
> in. gdb will also allow you to do 'up' to go up to the next level
> in the stack and then inspect variables there.
>
> Chris C
>
No, Chris,
keyword is a good string (i.e. with zero byte at the end etc.)
and in this moment I suggest with Pavel Holejsovsky:
>you must say:
>
>KeyWord = new char[strlen(keyword)+1]
>
>because strlen returns length of string without terminating '\0'
>character. Generally, strcpy(new char[strlen(x)], x) will cause memory
>corruption (one byte after allocated char array).
>
>If you say that first constructor passes OK and 2nd breaks, then it may
>be the cause - during first ctor you damage internal heap management
>flags used by operator new and it blows up on second call.
>
But I tried this without any success.
Alexander Bokovoy, <bokovoy AT bspu DOT ac DOT by>
---== The Soft Age coming soon ==---
- Raw text -