Date: Thu, 21 Aug 1997 18:54:41 -0200 Message-Id: <199708212054.SAA002.35@ns1.bspu.ac.by> To: Chris Croughton From: Alexander Bokovoy Cc: DJGPP mailing list Subject: Re[2]: SIGSEGV or SIGABRT during execution In-Reply-To: <97Aug21.165252gmt+0100.17025@internet01.amc.de> References: <97Aug21.165252gmt+0100 DOT 17025 AT internet01 DOT amc DOT de> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk On Thu, 21 Aug 1997 15:56:36 +0100 Chris Croughton 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, ---== The Soft Age coming soon ==---