Check-in Number:
|
2510 | |
Date: |
2002-Aug-14 14:30:16 (local)
2002-Aug-14 12:30:16 (UTC) |
User: | thl |
Branch: | |
Comment: |
consequently strdup and properly clean up; fix segfault reallocating too little space |
Tickets: |
|
Inspections: |
|
Files: |
|
ossp-pkg/lmtp2nntp/lmtp2nntp_option.c 1.20 -> 1.21
--- lmtp2nntp_option.c 2002/07/02 07:49:01 1.20
+++ lmtp2nntp_option.c 2002/08/14 12:30:16 1.21
@@ -319,18 +319,17 @@
try {
int largc;
- char *cpNew;
v.largv = (char **)mallocex((1 + 1) * sizeof(char **));
largc = 0;
- v.largv[largc++] = "leftover";
+ v.largv[largc] = NULL;
+ v.largv[largc++] = strdupex("leftover");
v.largv[largc] = NULL;
while ((cp = (char *)popt_getarg(poptCon)) != NULL) {
- v.largv = (char **)reallocex(v.largv, (largc + 2) * sizeof(char **));
- v.largv[largc++] = "--newsgroup";
+ v.largv = (char **)reallocex(v.largv, (1 + largc + 2) * sizeof(char **));
+ v.largv[largc++] = strdupex("--newsgroup");
v.largv[largc] = NULL;
- cpNew = strdupex(cp);
- v.largv[largc++] = cpNew;
+ v.largv[largc++] = strdupex(cp);
v.largv[largc] = NULL;
}
if (largc > 1) {
@@ -340,8 +339,11 @@
}
}
cleanup {
- if (v.largv != NULL)
+ if (v.largv != NULL) {
+ for (i = 0; v.largv[i] != NULL; i++)
+ free(v.largv[i]);
free(v.largv);
+ }
}
catch(ex) {
rethrow;
|
|