[R] main/character.c (et.al): dangerous AllocBuffer()

Peter Dalgaard BSA p.dalgaard at biostat.ku.dk
Wed Oct 13 15:40:27 CEST 1999


Thomas Hoffmann <hoffmann at ehmgs2.et.tu-dresden.de> writes:

> 	realloc(buff, 0);
> 	buff = (char *) realloc(buff, MAXELTSIZE);
> 	bufsize = MAXELTSIZE;
> 	
> But in the first call of realloc() it is perfectly legal to return a new pointer (which is thrown away 
> here), and then using (a possibly invalid) buff from earlier times may (and did for me) crash your 
> program.
...

> BTW, a check for failing [re,m]alloc may be appropriate.
>  		 
> I hope this list is the right one for comments of this kind.

Actually, r-devel is better, but thanks anyway...

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list