analyze: fix memleak and missing oom check

Follow-up for ad6e02e7b4.
This commit is contained in:
Yu Watanabe
2025-07-18 01:39:51 +09:00
parent 33502785de
commit 3bfc3414e6
3 changed files with 14 additions and 6 deletions
+5 -2
View File
@@ -63,8 +63,11 @@ int verb_unit_gdb(int argc, char *argv[], void *userdata) {
if (r < 0)
return log_error_errno(r, "Failed to read the main PID of %s from reply: %m", unit);
if (!arg_debugger)
arg_debugger = secure_getenv("SYSTEMD_DEBUGGER") ?: "gdb";
if (!arg_debugger) {
arg_debugger = strdup(secure_getenv("SYSTEMD_DEBUGGER") ?: "gdb");
if (!arg_debugger)
return log_oom();
}
_cleanup_strv_free_ char **debugger_call = NULL;
r = strv_extend(&debugger_call, arg_debugger);
+7 -3
View File
@@ -81,8 +81,8 @@ usec_t arg_fuzz = 0;
PagerFlags arg_pager_flags = 0;
CatFlags arg_cat_flags = 0;
BusTransport arg_transport = BUS_TRANSPORT_LOCAL;
const char *arg_debugger = NULL;
static char **arg_debugger_args = NULL;
char *arg_debugger = NULL;
char **arg_debugger_args = NULL;
const char *arg_host = NULL;
RuntimeScope arg_runtime_scope = RUNTIME_SCOPE_SYSTEM;
RecursiveErrors arg_recursive_errors = _RECURSIVE_ERRORS_INVALID;
@@ -109,6 +109,8 @@ char *arg_drm_device_path = NULL;
STATIC_DESTRUCTOR_REGISTER(arg_dot_from_patterns, strv_freep);
STATIC_DESTRUCTOR_REGISTER(arg_dot_to_patterns, strv_freep);
STATIC_DESTRUCTOR_REGISTER(arg_debugger, freep);
STATIC_DESTRUCTOR_REGISTER(arg_debugger_args, strv_freep);
STATIC_DESTRUCTOR_REGISTER(arg_root, freep);
STATIC_DESTRUCTOR_REGISTER(arg_image, freep);
STATIC_DESTRUCTOR_REGISTER(arg_security_policy, freep);
@@ -665,7 +667,9 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_DEBUGGER:
arg_debugger = strdup(optarg);
r = free_and_strdup_warn(&arg_debugger, optarg);
if (r < 0)
return r;
break;
case 'A': {
+2 -1
View File
@@ -24,7 +24,8 @@ extern PagerFlags arg_pager_flags;
extern CatFlags arg_cat_flags;
extern BusTransport arg_transport;
extern const char *arg_host;
extern const char *arg_debugger;
extern char *arg_debugger;
extern char **arg_debugger_args;
extern RuntimeScope arg_runtime_scope;
extern RecursiveErrors arg_recursive_errors;
extern bool arg_man;