mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-08 20:00:23 +01:00
core: fix memleak in nm_utils_get_start_time_for_pid() and parsing start-time
It was leaking @tokens in case of error. Also the error checking of
start-time with strtoull() was erroneous.
(cherry picked from commit 67057079a4)
This commit is contained in:
parent
cb29a2109f
commit
1cf9e989c1
1 changed files with 7 additions and 11 deletions
|
|
@ -317,10 +317,10 @@ guint64
|
|||
nm_utils_get_start_time_for_pid (pid_t pid, char *out_state)
|
||||
{
|
||||
guint64 start_time;
|
||||
gchar *filename;
|
||||
gchar *contents;
|
||||
gs_free gchar *filename = NULL;
|
||||
gs_free gchar *contents = NULL;
|
||||
size_t length;
|
||||
gchar **tokens;
|
||||
gs_strfreev gchar **tokens = NULL;
|
||||
guint num_tokens;
|
||||
gchar *p;
|
||||
gchar *endp;
|
||||
|
|
@ -356,19 +356,15 @@ nm_utils_get_start_time_for_pid (pid_t pid, char *out_state)
|
|||
if (num_tokens < 20)
|
||||
goto out;
|
||||
|
||||
errno = 0;
|
||||
start_time = strtoull (tokens[19], &endp, 10);
|
||||
if (endp == tokens[19])
|
||||
goto out;
|
||||
if (*endp != '\0' || errno != 0)
|
||||
start_time = 0;
|
||||
|
||||
g_strfreev (tokens);
|
||||
|
||||
out:
|
||||
out:
|
||||
if (out_state)
|
||||
*out_state = state;
|
||||
|
||||
g_free (filename);
|
||||
g_free (contents);
|
||||
|
||||
return start_time;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue