delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/26/03:02:40

From: Chris Frolik <frolikcc AT indy DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: SIGSEGV or SIGABRT during execution
Date: Mon, 25 Aug 1997 20:13:10 -0500
Organization: IndyNet - Indys Internet Gateway (info AT indy DOT net)
Lines: 20
Message-ID: <34022DA6.9A3@indy.net>
References: <199708211849 DOT QAA001 DOT 21 AT ns1 DOT bspu DOT ac DOT by>
NNTP-Posting-Host: ip91-37.ts.indy.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Alexander Bokovoy wrote:
> 
> Could somebody explain what is wrong in the next piece of code
> which is successfully compiled from RHIDE but during execution
> breaks with SIGSEGV (if execute from DOS) or SIGABRT (from RHIDE).
> Debugging shows that error occures in the next line:
> 
>      KeyWord=new char[strlen(keyword)]; // Create and fill key field
> 

strlen() returns the length of a string _without_ the null terminating
character.  Try changing the line as follows:

      KeyWord=new char[strlen(keyword)+1];

And see if it works.  BTW, although variable names are case sensitive,
it is less confusing to use names that are spelled differently, rather
than KeyWord and keyword.

-Chris

- Raw text -


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