File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -279,17 +279,22 @@ PROTOSTYLE ReadProtoStyle(FILE *File) {
279
279
* @note History: 6/6/89, DSJ, Created.
280
280
*/
281
281
FLOAT32* ReadNFloats (FILE * File, uinT16 N, FLOAT32 Buffer[]) {
282
+ bool needs_free = false ;
282
283
int i;
283
284
int NumFloatsRead;
284
285
285
- if (Buffer == NULL )
286
+ if (Buffer == NULL ) {
286
287
Buffer = reinterpret_cast <FLOAT32*>(Emalloc (N * sizeof (FLOAT32)));
288
+ needs_free = true ;
289
+ }
287
290
288
291
for (i = 0 ; i < N; i++) {
289
292
NumFloatsRead = tfscanf (File, " %f" , &(Buffer[i]));
290
293
if (NumFloatsRead != 1 ) {
291
294
if ((NumFloatsRead == EOF) && (i == 0 )) {
292
- Efree (Buffer);
295
+ if (needs_free) {
296
+ Efree (Buffer);
297
+ }
293
298
return NULL ;
294
299
} else {
295
300
DoError (ILLEGALFLOAT, " Illegal float specification" );
You can’t perform that action at this time.
0 commit comments