@@ -155,13 +155,23 @@ void lingot_test_io_config(void) {
155
155
156
156
// we check that we can save and load it again
157
157
158
- filename = tmpnam (NULL );
159
- lingot_io_config_save (config , filename );
160
- ok = lingot_io_config_load (config , filename );
158
+ // although the use of tmpnam() is flagged as 'dangerous', it is the only
159
+ // standard way to get the temp file name with full path, and it is used
160
+ // only during the tests anyway.
161
+ char temp_filename_buffer [L_tmpnam ];
162
+ char * temp_filename ;
163
+ temp_filename = tmpnam (temp_filename_buffer );
164
+ if (!temp_filename ) {
165
+ fprintf (stderr , "%s\n" , "warning: temporary file cannot be created" );
166
+ return ; // we allow to continue with the distcheck.
167
+ }
168
+
169
+ lingot_io_config_save (config , temp_filename );
170
+ ok = lingot_io_config_load (config , temp_filename );
161
171
CU_ASSERT (ok );
162
172
check_last_configs (config );
163
173
164
- ok = !remove (filename );
174
+ ok = !remove (temp_filename );
165
175
CU_ASSERT (ok );
166
176
167
177
// -----------
@@ -174,13 +184,17 @@ void lingot_test_io_config(void) {
174
184
175
185
// we check that we can save and load it again
176
186
177
- filename = tmpnam (NULL );
178
- lingot_io_config_save (config , filename );
179
- ok = lingot_io_config_load (config , filename );
187
+ temp_filename = tmpnam (temp_filename_buffer );
188
+ if (!temp_filename ) {
189
+ fprintf (stderr , "%s\n" , "warning: temporary file cannot be created" );
190
+ return ; // we allow to continue with the distcheck.
191
+ }
192
+ lingot_io_config_save (config , temp_filename );
193
+ ok = lingot_io_config_load (config , temp_filename );
180
194
CU_ASSERT (ok );
181
195
check_last_configs (config );
182
196
183
- ok = !remove (filename );
197
+ ok = !remove (temp_filename );
184
198
CU_ASSERT (ok );
185
199
186
200
// -----------
0 commit comments