From tom@@@k@||ber@ @end|ng |rom gm@||@com  Thu Jul 13 08:59:01 2023
From: tom@@@k@||ber@ @end|ng |rom gm@||@com (Tomas Kalibera)
Date: Thu, 13 Jul 2023 08:59:01 +0200
Subject: [Rd] Incorrect type in malloc in Rscript.c
In-Reply-To: <69F17DDB-3725-42F7-AE2B-5682C4AE82AA@gmail.com>
References: <69F17DDB-3725-42F7-AE2B-5682C4AE82AA@gmail.com>
Message-ID: <95590b13-e657-16af-b6a8-8d2921ec8c5e@gmail.com>


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 at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] Incorrect type in malloc in Rscript.c
Tomas Kalibera