🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.unix.programmer
Article #172

Re: I am stumped by this one!!!

#172
From: ross andrus
Date: Tue, 28 Jul 1992 18:52
45 lines
2355 bytes
In article <1992Jul27.134826.5592@cbfsb.cb.att.com> rajeev@cbnewsf.cb.att.com (rajeev.dolas) writes:
>In article <13744@auspex-gw.auspex.com> guy@Auspex.COM (Guy Harris) writes:
>>>>		cp_line = (char *)malloc(sizeof(strlen(pars_wbuf)));
>>>

  // stuff deleted

>>No, try it again with:
>>
>>>	cp_line = (char*)malloc(strlen(pars_wbuf) + 1);
>>

  // stuff deleted

>
>	I realize the error on sizeof instead of strlen() for malloc. But
>	I don't think that is the cause of SEGV error. If you look at my
>	original posting, you will notice that I am able to copy selected
>	characters to cp_line.

  Have you actually changed the code as Guy suggested and tried it? If not,
  you're only allocating sizeof(int) bytes for cp_line. If you ever try to
  put more than that many bytes there, you are almost guaranteed to hose
  your storage arena. After which the only thing between you and a core 
  file is time and execution flow - i.e. luck.

>	In my original code I wasn't even using the cp_line. I was reading
>	a char pointed to by *pbuf and was writing that to the file. I
>	got the SEGV error on the putc()!!! Now I am using fputs() to
>	write a string instead of a char and I get the same error on
>	fputs(). Also fputs(tmp_line,stdout) works fine while 
>	fputs(tmp_line,fp1) does not!!! That's what is driving me nuts.

  Hmm. You might comb the rest of your code for stepping-on-memory problems 
  similar to the above. What you've described certainly - has that feel to it. 
  I would probably not conclude that the library was busted.

  Good luck

  ross
-- 
+-----------------------------------------------------------------------------+
|  Ross Andrus  == ross@insci.com					      |
|  Clever Disclaimer.							      |
+-----------------------------------------------------------------------------+
Technical Details
Message-ID: <1992Jul28.185259.2571@spike.insci.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!psinntp!spike.insci.com!augie!ross
References: <Brx394.4qL@undergrad.math.waterloo.edu> <13744@auspex-gw.auspex.com> <1992Jul27.134826.5592@cbfsb.cb.att.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.unix.programmer
Path: arc1-ca.pugleaf.net!sparky!uunet!psinntp!spike.insci.com!augie!ross
From: ross@augie.insci.com (ross andrus)
Subject: Re: I am stumped by this one!!!
Organization: Insci Incorporated
Distribution: usa
Date: Tue, 28 Jul 1992 18:52:59 GMT
Message-ID: <1992Jul28.185259.2571@spike.insci.com>
References: <Brx394.4qL@undergrad.math.waterloo.edu> <13744@auspex-gw.auspex.com> <1992Jul27.134826.5592@cbfsb.cb.att.com>
Sender: news@spike.insci.com (News spooler)
Lines: 45