comparison common/listutil.c @ 38:fc6241283474

Fix resource leak when file too large
author Andre Heinecke <aheinecke@intevation.de>
date Fri, 14 Mar 2014 09:05:11 +0000
parents 37fc66967517
children 5cb1eb928253
comparison
equal deleted inserted replaced
37:00aa5fa3c2fb 38:fc6241283474
63 } 63 }
64 64
65 fseek(f, 0, SEEK_SET); 65 fseek(f, 0, SEEK_SET);
66 66
67 if (file_size + 1 == 0) { 67 if (file_size + 1 == 0) {
68 fclose(f);
68 return READ_FILE_TOO_LARGE; 69 return READ_FILE_TOO_LARGE;
69 } 70 }
70 *size = (size_t) file_size; 71 *size = (size_t) file_size;
71 72
72 if (*size > max_size) 73 if (*size > max_size) {
74 fclose(f);
73 return READ_FILE_TOO_LARGE; 75 return READ_FILE_TOO_LARGE;
76 }
74 77
75 *data = (char *) malloc( *size + 1 ); 78 *data = (char *) malloc( *size + 1 );
76 if (data == NULL) { 79 if (data == NULL) {
77 fclose(f); 80 fclose(f);
78 return READ_FILE_NO_MEMORY; 81 return READ_FILE_NO_MEMORY;

http://wald.intevation.org/projects/trustbridge/