delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/21/11:08:30

Message-ID: <87BC54A997CCD01198930020AFF6011C2BA6BE@mail.rkk.cz>
From: "Holejsovsky, Pavel" <PHolejs AT rkk DOT cz>
To: "'Alexander Bokovoy'" <bokovoy AT bspu DOT ac DOT by>
Cc: "'djgpp AT delorie DOT com'" <djgpp AT delorie DOT com>
Subject: RE: SIGSEGV or SIGABRT during execution
Date: Thu, 21 Aug 1997 17:03:31 +0200
MIME-Version: 1.0

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.

Pavel

P.S. Sorry about not quoting your mail, but either this stuuupiiid M$
mailer is totally broken, or I'm much more stupid and I can't use it.
grrrr.... 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019