[Rd] Incorrect type in malloc in Rscript.c

Tomas Kalibera tom@@@k@||ber@ @end|ng |rom gm@||@com
Thu Jul 13 08:59:01 CEST 2023


On 7/13/23 00:26, Will McClennan wrote:
> I downloaded and compiled R-4.3.1 from cran.rstudio.com and on line 405 of Rscript.c in src/unix the line of code
>
> char *buf=(char*) malloc((size_t) (len+1)*sizeof(char *));
>
> appears to be wrong to me. If an array of char* is being allocated then the argument to sizeof should be char and not char*. On a 64 bit machine this will allocate 8 times as much memory as needed. For this reason the code works but it is an incorrect. Not a big issue though.

Thanks, fixed now.

Tomas

>
> Will McClennan
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



More information about the R-devel mailing list