Skip to content

Commit be949fd

Browse files
committed
fix memory leak in config_get_opt
1 parent 0e1227b commit be949fd

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/utils/configuration.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,9 @@ config_get_opt(int argc, char **argv, ConfigOption cmd_options[],
538538
assign_option(opt, optarg, SOURCE_CMD);
539539
}
540540

541+
pgut_free(optstring);
542+
pgut_free(longopts);
543+
541544
return optind;
542545
}
543546

src/utils/pgut.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,12 @@ pgut_str_strip_trailing_filename(const char *filepath, const char *filename)
993993
return pgut_strndup(filepath, fp_len);
994994
}
995995

996+
void
997+
pgut_free(void *p)
998+
{
999+
free(p);
1000+
}
1001+
9961002
FILE *
9971003
pgut_fopen(const char *path, const char *mode, bool missing_ok)
9981004
{

src/utils/pgut.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ extern void *pgut_realloc(void *p, size_t size);
6464
extern char *pgut_strdup(const char *str);
6565
extern char *pgut_strndup(const char *str, size_t n);
6666
extern char *pgut_str_strip_trailing_filename(const char *filepath, const char *filename);
67+
extern void pgut_free(void *p);
6768

6869
#define pgut_new(type) ((type *) pgut_malloc(sizeof(type)))
6970
#define pgut_new0(type) ((type *) pgut_malloc0(sizeof(type)))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy