diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-11 12:19:14 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-11 12:19:14 +0000 |
commit | dee8587d9208e4ea5ba8f8bb73b555007529372e (patch) | |
tree | 303d21aeec9e3922e296ecc9041598a87a79b554 /miscutils/man.c | |
parent | f941306199d7cb00be68483169f202432a9a9a7d (diff) | |
download | busybox-w32-dee8587d9208e4ea5ba8f8bb73b555007529372e.tar.gz busybox-w32-dee8587d9208e4ea5ba8f8bb73b555007529372e.tar.bz2 busybox-w32-dee8587d9208e4ea5ba8f8bb73b555007529372e.zip |
Apply post-1.11.0 patches. Bump version to 1.11.1.
Diffstat (limited to 'miscutils/man.c')
-rw-r--r-- | miscutils/man.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/miscutils/man.c b/miscutils/man.c index 278e5a336..dc8fa449d 100644 --- a/miscutils/man.c +++ b/miscutils/man.c | |||
@@ -73,7 +73,7 @@ int man_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
73 | char *sec_list; | 73 | char *sec_list; |
74 | char *cur_path, *cur_sect; | 74 | char *cur_path, *cur_sect; |
75 | char *line, *value; | 75 | char *line, *value; |
76 | int count_mp, alloc_mp, cur_mp; | 76 | int count_mp, cur_mp; |
77 | int opt; | 77 | int opt; |
78 | 78 | ||
79 | opt_complementary = "-1"; /* at least one argument */ | 79 | opt_complementary = "-1"; /* at least one argument */ |
@@ -81,8 +81,8 @@ int man_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
81 | argv += optind; | 81 | argv += optind; |
82 | 82 | ||
83 | sec_list = xstrdup("1:2:3:4:5:6:7:8:9"); | 83 | sec_list = xstrdup("1:2:3:4:5:6:7:8:9"); |
84 | alloc_mp = 10; | 84 | /* Last valid man_path_list[] is [0x10] */ |
85 | man_path_list = xmalloc(10 * sizeof(man_path_list[0])); | 85 | man_path_list = xzalloc(0x11 * sizeof(man_path_list[0])); |
86 | count_mp = 0; | 86 | count_mp = 0; |
87 | man_path_list[0] = xstrdup(getenv("MANPATH")); | 87 | man_path_list[0] = xstrdup(getenv("MANPATH")); |
88 | if (man_path_list[0]) | 88 | if (man_path_list[0]) |
@@ -107,11 +107,13 @@ int man_main(int argc ATTRIBUTE_UNUSED, char **argv) | |||
107 | if (strcmp("MANPATH", line) == 0) { | 107 | if (strcmp("MANPATH", line) == 0) { |
108 | man_path_list[count_mp] = xstrdup(value); | 108 | man_path_list[count_mp] = xstrdup(value); |
109 | count_mp++; | 109 | count_mp++; |
110 | if (alloc_mp == count_mp) { | 110 | /* man_path_list is NULL terminated */ |
111 | alloc_mp += 10; | 111 | man_path_list[count_mp] = NULL; |
112 | man_path_list = xrealloc(man_path_list, alloc_mp * sizeof(man_path_list[0])); | 112 | if (!(count_mp & 0xf)) { /* 0x10, 0x20 etc */ |
113 | /* so that last valid man_path_list[] is [count_mp + 0x10] */ | ||
114 | man_path_list = xrealloc(man_path_list, | ||
115 | (count_mp + 0x11) * sizeof(man_path_list[0])); | ||
113 | } | 116 | } |
114 | /* thus man_path_list is always NULL terminated */ | ||
115 | } | 117 | } |
116 | if (strcmp("MANSECT", line) == 0) { | 118 | if (strcmp("MANSECT", line) == 0) { |
117 | free(sec_list); | 119 | free(sec_list); |