projects
/
lttng-tools.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: lttng-clear: invalid free of session name
[lttng-tools.git]
/
src
/
bin
/
lttng
/
commands
/
clear.c
diff --git
a/src/bin/lttng/commands/clear.c
b/src/bin/lttng/commands/clear.c
index 353c855c6f11aed6036f6a8f855035d31d7f8b54..24db9f37e89fb819e37e10dc4bdd349056c001b0 100644
(file)
--- a/
src/bin/lttng/commands/clear.c
+++ b/
src/bin/lttng/commands/clear.c
@@
-168,7
+168,7
@@
int cmd_clear(int argc, const char **argv)
static poptContext pc;
char *session_name = NULL;
const char *leftover = NULL;
static poptContext pc;
char *session_name = NULL;
const char *leftover = NULL;
-
+ bool free_session_name = false;
struct lttng_session *sessions = NULL;
int count;
int found;
struct lttng_session *sessions = NULL;
int count;
int found;
@@
-224,13
+224,7
@@
int cmd_clear(int argc, const char **argv)
}
if (!opt_clear_all) {
}
if (!opt_clear_all) {
- /*
- * popt expects us to free this even if it returns a const char *.
- * See https://www.mail-archive.com/popt-devel@rpm5.org/msg00193.html
- * Force cast to char * allowing later freeing if necessary.
- */
session_name = (char *) poptGetArg(pc);
session_name = (char *) poptGetArg(pc);
-
if (!session_name) {
/* No session name specified, lookup default */
session_name = get_session_name();
if (!session_name) {
/* No session name specified, lookup default */
session_name = get_session_name();
@@
-239,6
+233,7
@@
int cmd_clear(int argc, const char **argv)
success = 0;
goto mi_closing;
}
success = 0;
goto mi_closing;
}
+ free_session_name = true;
}
} else {
session_name = NULL;
}
} else {
session_name = NULL;
@@
-323,7
+318,9
@@
end:
}
free(sessions);
}
free(sessions);
- free(session_name);
+ if (free_session_name) {
+ free(session_name);
+ }
/* Overwrite ret if an error occurred during clear_session/all */
ret = command_ret ? command_ret : ret;
/* Overwrite ret if an error occurred during clear_session/all */
ret = command_ret ? command_ret : ret;
This page took
0.023868 seconds
and
4
git commands to generate.