Merge branch 'fix-s-format-null' into 'master'

up: %s may be null check pointer on null safety from UB

See merge request upower/upower!319
This commit is contained in:
Herman Semenov 2026-04-29 11:56:05 -12:00
commit e6f4fd8b49
5 changed files with 14 additions and 9 deletions

View file

@ -499,7 +499,8 @@ up_device_get_history_sync (UpDevice *device, const gchar *type, guint timespec,
NULL,
&error_local);
if (!ret) {
g_set_error (error, 1, 0, "GetHistory(%s,%i) on %s failed: %s", type, timespec,
if (error_local->message)
g_set_error (error, 1, 0, "GetHistory(%s,%i) on %s failed: %s", type, timespec,
up_device_get_object_path (device), error_local->message);
g_error_free (error_local);
goto out;
@ -576,7 +577,8 @@ up_device_get_statistics_sync (UpDevice *device, const gchar *type, GCancellable
NULL,
&error_local);
if (!ret) {
g_set_error (error, 1, 0, "GetStatistics(%s) on %s failed: %s", type,
if (error_local->message)
g_set_error (error, 1, 0, "GetStatistics(%s) on %s failed: %s", type,
up_device_get_object_path (device), error_local->message);
g_error_free (error_local);
goto out;

View file

@ -324,7 +324,8 @@ up_device_wup_coldplug (UpDevice *device)
/* dummy read */
data = up_device_wup_read_command (wup);
g_debug ("data after clear %s", data);
if (data)
g_debug ("data after clear %s", data);
/* shouldn't do anything */
up_device_wup_parse_command (wup, data);

View file

@ -240,8 +240,8 @@ power_supply_add_helper (UpEnumeratorUdev *self,
/* Fire relevant sibling events and insert into lookup table */
parent_id = device_parent_id (device);
g_debug ("device %s has parent id: %s", device_key, parent_id);
if (parent_id) {
g_debug ("device %s has parent id: %s", device_key, parent_id);
GPtrArray *devices = NULL;
char *parent_id_key = NULL;
int i;

View file

@ -222,7 +222,8 @@ up_input_coldplug (UpInput *input, GUdevDevice *d)
/* convert to a bitmask */
num_bits = up_input_str_to_bitmask (contents, bitmask, sizeof (bitmask));
if ((num_bits == 0) || (num_bits >= SW_CNT)) {
g_debug ("invalid bitmask entry for %s", native_path);
if (native_path)
g_debug ("invalid bitmask entry for %s", native_path);
ret = FALSE;
goto out;
}

View file

@ -325,10 +325,11 @@ up_device_kbd_backlight_initable_init (GInitable *initable,
if (klass->coldplug != NULL) {
ret = klass->coldplug (device);
if (!ret) {
g_debug ("failed to coldplug %s", native_path);
g_propagate_error (error, g_error_new (G_IO_ERROR, G_IO_ERROR_FAILED,
"Failed to coldplug %s", native_path));
if (native_path) {
g_debug ("failed to coldplug %s", native_path);
g_propagate_error (error, g_error_new (G_IO_ERROR, G_IO_ERROR_FAILED,
"Failed to coldplug %s", native_path));
}
return FALSE;
}
}