Constify opt_f and opt_t and eliminate unneeded copying. This fixes
memory leaks. Reported by: clang static analyzer MFC after: 2 weeks
This commit is contained in:
parent
3b0fd911fa
commit
670f01434e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=287319
@ -156,11 +156,11 @@ int
|
|||||||
main(int argc, char **argv)
|
main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char *opt_f, *opt_t;
|
const char *opt_f, *opt_t;
|
||||||
int ch, i, res;
|
int ch, i, res;
|
||||||
bool opt_c = false, opt_s = false;
|
bool opt_c = false, opt_s = false;
|
||||||
|
|
||||||
opt_f = opt_t = strdup("");
|
opt_f = opt_t = "";
|
||||||
|
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
setprogname(argv[0]);
|
setprogname(argv[0]);
|
||||||
@ -186,12 +186,12 @@ main(int argc, char **argv)
|
|||||||
case 'f':
|
case 'f':
|
||||||
/* from */
|
/* from */
|
||||||
if (optarg != NULL)
|
if (optarg != NULL)
|
||||||
opt_f = strdup(optarg);
|
opt_f = optarg;
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
/* to */
|
/* to */
|
||||||
if (optarg != NULL)
|
if (optarg != NULL)
|
||||||
opt_t = strdup(optarg);
|
opt_t = optarg;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
|
Loading…
Reference in New Issue
Block a user