diff options
author | jbj <jbj> | 2016-06-24 19:04:19 +0000 |
---|---|---|
committer | jbj <jbj> | 2016-06-24 19:04:19 +0000 |
commit | 9348ab09e1a92df2e248e416d1161d01a97ed2bb (patch) | |
tree | 00b836033e3c8b70a469285d3ceff2585e8d9512 | |
parent | 935f3f1b474c8f386b8de4e2b1a04909b9bc91d8 (diff) | |
download | libpopt-9348ab09e1a92df2e248e416d1161d01a97ed2bb.tar.gz |
- use poptArgvFree to avoid memory leaks.
-rw-r--r-- | CHANGES | 1 | ||||
-rw-r--r-- | libpopt.vers | 1 | ||||
-rw-r--r-- | popt.c | 7 | ||||
-rw-r--r-- | popt.h | 9 | ||||
-rw-r--r-- | poptparse.c | 2 |
5 files changed, 11 insertions, 9 deletions
@@ -1,4 +1,5 @@ 1.17 -> 2.0: + - jbj: use poptArgvFree to avoid memory leaks. - jbj: i18n: update PO files (Translation Project). - jbj: i18n: update PO files (Translation Project). - jbj: i18n: update da fr nb nl uk, and msgmerge (Translation Project). diff --git a/libpopt.vers b/libpopt.vers index 3ac5e52..b736801 100644 --- a/libpopt.vers +++ b/libpopt.vers @@ -8,6 +8,7 @@ LIBPOPT_0 poptAddAlias; poptAddItem; poptAliasOptions; + poptArgvFree; poptBadOption; _poptBitsN; _poptBitsM; @@ -1770,12 +1770,7 @@ poptItem poptFreeItems(/*@only@*/ /*@null@*/ poptItem items, int nitems) if (items != NULL) { poptItem item = items; while (--nitems >= 0) { -#if !defined(SUPPORT_CONTIGUOUS_ARGV) - int i; - for (i = 0; item->argv[i]; i++) - item->argv[i] = _free(item->argv[i]); -#endif - item->argv = _free(item->argv); + item->argv = poptArgvFree(item->argv); /*@-modobserver -observertrans -dependenttrans@*/ item->option.longName = _free(item->option.longName); item->option.descrip = _free(item->option.descrip); @@ -470,8 +470,6 @@ int poptDupArgv(int argc, /*@null@*/ const char **argv, * Parse a string into an argument array. * The parse allows ', ", and \ quoting, but ' is treated the same as " and * both may include \ quotes. - * @note: The argument array is malloc'd as a single area, so only argv must - * be free'd. * * @param s string to parse * @retval argcPtr address of returned no. of arguments @@ -482,6 +480,13 @@ int poptParseArgvString(const char * s, /*@modifies *argcPtr, *argvPtr @*/; /** \ingroup popt + * Free the argument array. + * @param argv argument array. + * @retval NULL always + */ +const char ** poptArgvFree(const char ** argv); + +/** \ingroup popt * Parses an input configuration file and returns an string that is a * command line. For use with popt. You must free the return value when done. * diff --git a/poptparse.c b/poptparse.c index 819d30b..6c3fa73 100644 --- a/poptparse.c +++ b/poptparse.c @@ -16,7 +16,7 @@ #define assert(_x) #endif -static const char ** poptArgvFree(/*@only@*/ const char ** av) +const char ** poptArgvFree(/*@only@*/ const char ** av) { #if !defined(SUPPORT_CONTIGUOUS_ARGV) if (av) { |