mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-05 10:20:14 +01:00
cloud-setup: don't use a GString in _get_config_ips_list_cb()
nm_utils_parse_next_line() operates on the response buffer obtained from NMHttpClient. We own this buffer, and we also can rely on the fact that the buffer has a trailing NUL byte after the data. There is no need to clone the string to a GString, just use it directly.
This commit is contained in:
parent
c9c54709b8
commit
62aec7acd3
1 changed files with 9 additions and 10 deletions
|
|
@ -255,21 +255,20 @@ _get_config_ips_list_cb (GObject *source,
|
|||
&response_len,
|
||||
&line,
|
||||
&line_len)) {
|
||||
nm_auto_free_gstring GString *gstr = NULL;
|
||||
gint64 fip_index;
|
||||
|
||||
gstr = g_string_new_len (line, line_len);
|
||||
fip_index = _nm_utils_ascii_str_to_int64 (gstr->str, 10, 0, G_MAXINT64, -1);
|
||||
/* Truncate the string. It's safe to do, because we own @response_data an it has an
|
||||
* extra NUL character after the buffer. */
|
||||
((char *) line)[line_len] = '\0';
|
||||
|
||||
if (fip_index < 0) {
|
||||
fip_index = _nm_utils_ascii_str_to_int64 (line, 10, 0, G_MAXINT64, -1);
|
||||
if (fip_index < 0)
|
||||
continue;
|
||||
}
|
||||
|
||||
g_string_printf (gstr,
|
||||
"%"G_GSSIZE_FORMAT"/forwarded-ips/%"G_GINT64_FORMAT,
|
||||
iface_data->iface_idx,
|
||||
fip_index);
|
||||
g_ptr_array_add (uri_arr, g_string_free (g_steal_pointer (&gstr), FALSE));
|
||||
g_ptr_array_add (uri_arr,
|
||||
g_strdup_printf ("%"G_GSSIZE_FORMAT"/forwarded-ips/%"G_GINT64_FORMAT,
|
||||
iface_data->iface_idx,
|
||||
fip_index));
|
||||
}
|
||||
|
||||
iface_data->n_fips_pending = uri_arr->len;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue