summaryrefslogtreecommitdiff
path: root/fsck_minix.c
diff options
context:
space:
mode:
authorJohn Beppu <beppu@lbox.org>2000-02-11 12:52:55 +0000
committerJohn Beppu <beppu@lbox.org>2000-02-11 12:52:55 +0000
commit5e1b2ca1161cba481ccf4873427389f59dbc23e0 (patch)
treebe383c16e82d92c627a2080a5e711830cfc4d046 /fsck_minix.c
parentfa376f80348b4241124c8e4c727bcb57181e50d1 (diff)
downloadbusybox-w32-5e1b2ca1161cba481ccf4873427389f59dbc23e0.tar.gz
busybox-w32-5e1b2ca1161cba481ccf4873427389f59dbc23e0.tar.bz2
busybox-w32-5e1b2ca1161cba481ccf4873427389f59dbc23e0.zip
+ memory allocation/deallocation is less tolerant of evil.
Diffstat (limited to 'fsck_minix.c')
-rw-r--r--fsck_minix.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/fsck_minix.c b/fsck_minix.c
index 9da79748f..cfa973ecf 100644
--- a/fsck_minix.c
+++ b/fsck_minix.c
@@ -146,7 +146,7 @@ static int termios_set = 0;
146#define MAX_DEPTH 32 146#define MAX_DEPTH 32
147static int name_depth = 0; 147static int name_depth = 0;
148// static char name_list[MAX_DEPTH][PATH_MAX + 1]; 148// static char name_list[MAX_DEPTH][PATH_MAX + 1];
149static char **name_list; 149static char **name_list = NULL;
150 150
151static char *inode_buffer = NULL; 151static char *inode_buffer = NULL;
152 152
@@ -1248,14 +1248,33 @@ static void alloc_name_list(void)
1248 int i; 1248 int i;
1249 1249
1250 name_list = malloc(sizeof(char *) * MAX_DEPTH); 1250 name_list = malloc(sizeof(char *) * MAX_DEPTH);
1251 if (!name_list) {
1252 fprintf(stderr,"fsck_minix: name_list: %s\n", strerror(errno));
1253 exit(1);
1254 }
1251 for (i = 0; i < MAX_DEPTH; i++) { 1255 for (i = 0; i < MAX_DEPTH; i++) {
1252 name_list[i] = malloc(sizeof(char) * PATH_MAX + 1); 1256 name_list[i] = malloc(sizeof(char) * PATH_MAX + 1);
1257 if (!name_list[i]) {
1258 fprintf(stderr,"fsck_minix: name_list: %s\n", strerror(errno));
1259 exit(1);
1260 }
1253 } 1261 }
1254} 1262}
1255 1263
1264/* execute this atexit() to deallocate name_list[] */
1265/* piptigger was here */
1256static void free_name_list(void) 1266static void free_name_list(void)
1257{ 1267{
1258 if (name_list) free(name_list); 1268 int i;
1269
1270 if (name_list) {
1271 for (i = 0; i < MAX_DEPTH; i++) {
1272 if (name_list[i]) {
1273 free(name_list[i]);
1274 }
1275 }
1276 free(name_list);
1277 }
1259} 1278}
1260 1279
1261extern int fsck_minix_main(int argc, char **argv) 1280extern int fsck_minix_main(int argc, char **argv)