88 * This source code is licensed under BSD 3-Clause License (the "License").
99 * You may not use this file except in compliance with the License.
1010 * You may obtain a copy of the License at
11- *
11+ *
1212 * https://opensource.org/licenses/BSD-3-Clause
1313 */
1414
@@ -115,9 +115,11 @@ complete_cmd(const char *buf, const char *hint, linenoiseCompletions *lc)
115115char *
116116readinput (const char * instruction , const char * old_tmp , char * * new_tmp )
117117{
118- int tmpfd = -1 , ret , size , oldfd ;
118+ volatile int tmpfd = -1 ;
119+ int ret , size , oldfd ;
119120 pid_t pid , wait_pid ;
120- char * tmpname = NULL , * input = NULL , * old_content = NULL , * ptr , * ptr2 ;
121+ char * volatile input = NULL , * volatile old_content = NULL ;
122+ char * tmpname = NULL , * ptr , * ptr2 ;
121123
122124 /* Create a unique temporary file */
123125#ifdef HAVE_MKSTEMPS
@@ -226,7 +228,7 @@ readinput(const char *instruction, const char *old_tmp, char **new_tmp)
226228 lseek (tmpfd , 0 , SEEK_SET );
227229
228230 /* Read the input */
229- input = malloc (size + 1 );
231+ input = malloc (size + 1 );
230232 ret = read (tmpfd , input , size );
231233 if (ret < size ) {
232234 ERROR (__func__ , "Failed to read from the temporary file (%s)." , strerror (errno ));
@@ -244,7 +246,7 @@ readinput(const char *instruction, const char *old_tmp, char **new_tmp)
244246 /* The user could have deleted or modified the comment, ignore it then */
245247 if (ptr2 ) {
246248 ptr2 += 5 ;
247- memmove (ptr , ptr2 , strlen (ptr2 )+ 1 );
249+ memmove (ptr , ptr2 , strlen (ptr2 ) + 1 );
248250
249251 /* Save the modified content */
250252 if (ftruncate (tmpfd , 0 ) == -1 ) {
0 commit comments