diff options
author | Charles Kerr <charles.kerr@canonical.com> | 2012-06-01 13:43:40 -0500 |
---|---|---|
committer | Charles Kerr <charles.kerr@canonical.com> | 2012-06-01 13:43:40 -0500 |
commit | 5b17593fb388ab9febc2e4bc26d8054a34dd58c0 (patch) | |
tree | 280c1ff12f8207d255f1ec27f1ad49c284feeec6 | |
parent | 4c433bf6980f43c5fca5d7c86b167f50cc0295fd (diff) | |
download | ayatana-indicator-power-5b17593fb388ab9febc2e4bc26d8054a34dd58c0.tar.gz ayatana-indicator-power-5b17593fb388ab9febc2e4bc26d8054a34dd58c0.tar.bz2 ayatana-indicator-power-5b17593fb388ab9febc2e4bc26d8054a34dd58c0.zip |
Fix edge case in indicator_power_device_get_icon_names() that returned a bad value if the caller passed in a NULL pointer as a device. Added regression test.
-rw-r--r-- | src/device.c | 2 | ||||
-rw-r--r-- | tests/test-device.cc | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/device.c b/src/device.c index ac03009..b163682 100644 --- a/src/device.c +++ b/src/device.c @@ -307,7 +307,7 @@ indicator_power_device_get_icon_names (const IndicatorPowerDevice * device) const gchar *index_str; /* LCOV_EXCL_START */ - g_return_val_if_fail (INDICATOR_IS_POWER_DEVICE(device), UP_DEVICE_KIND_UNKNOWN); + g_return_val_if_fail (INDICATOR_IS_POWER_DEVICE(device), NULL); /* LCOV_EXCL_STOP */ gdouble percentage = indicator_power_device_get_percentage (device); diff --git a/tests/test-device.cc b/tests/test-device.cc index 1233133..525eee0 100644 --- a/tests/test-device.cc +++ b/tests/test-device.cc @@ -224,6 +224,9 @@ TEST_F(DeviceTest, IconNames) IndicatorPowerDevice * device = INDICATOR_POWER_DEVICE (g_object_new (INDICATOR_POWER_DEVICE_TYPE, NULL)); GObject * o = G_OBJECT(device); + /* bad arguments */ + ASSERT_TRUE (indicator_power_device_get_icon_names (NULL) == NULL); + /* power */ g_object_set (o, INDICATOR_POWER_DEVICE_KIND, UP_DEVICE_KIND_LINE_POWER, NULL); |