[Rd] Incorrect type in malloc in Rscript.c

Will McClennan w||||@m@mcc|enn@n @end|ng |rom gm@||@com
Thu Jul 13 00:26:56 CEST 2023


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.

Will McClennan


More information about the R-devel mailing list