Merge lp:~stolowski/unity-2d/check-xlistinputdevices-ptr into lp:unity-2d

Proposed by Paweł Stołowski
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 1056
Merged at revision: 1055
Proposed branch: lp:~stolowski/unity-2d/check-xlistinputdevices-ptr
Merge into: lp:unity-2d
Diff against target: 54 lines (+20/-18)
1 file modified
libunity-2d-private/src/keymonitor.cpp (+20/-18)
To merge this branch: bzr merge lp:~stolowski/unity-2d/check-xlistinputdevices-ptr
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Approve
Review via email: mp+101403@code.launchpad.net

Commit message

Check list pointer returned by XListInputDevices, as it may be null in VNC session, while XListInputDevices indicates positive number of devices. This would crash unity-2d-shell.

Description of the change

Check list pointer returned by XListInputDevices, as it may be null in VNC session, while XListInputDevices indicates positive number of devices. This would crash unity-2d-shell.
UNBLOCK

To post a comment you must log in.
1056. By Paweł Stołowski

Changed NULL pointer condition.

Revision history for this message
Albert Astals Cid (aacid) wrote :

Makes sense

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libunity-2d-private/src/keymonitor.cpp'
--- libunity-2d-private/src/keymonitor.cpp 2011-10-28 22:18:46 +0000
+++ libunity-2d-private/src/keymonitor.cpp 2012-04-10 16:10:28 +0000
@@ -98,30 +98,32 @@
9898
99 devices = XListInputDevices(m_display, &num_devices);99 devices = XListInputDevices(m_display, &num_devices);
100100
101 for(i=0; i<num_devices; i++) {101 /* Check returned list pointer as XListInputDevices may return NULL with num_devices>0, see LP: #965464 */
102 device = XOpenDevice(m_display, devices[i].id);102 if (devices != NULL) {
103 if (device == NULL) {103 for(i=0; i<num_devices; i++) {
104 /* That's not critical since "Virtual core..." devices don't104 device = XOpenDevice(m_display, devices[i].id);
105 allow opening. */105 if (device == NULL) {
106 UQ_DEBUG << "Could not open device: " << devices[i].name;106 /* That's not critical since "Virtual core..." devices don't
107 continue;107 allow opening. */
108 }108 UQ_DEBUG << "Could not open device: " << devices[i].name;
109 continue;
110 }
109111
110 if (devices[i].use == IsXExtensionKeyboard) {112 if (devices[i].use == IsXExtensionKeyboard) {
111 for (info=device->classes, j=0; j < device->num_classes; j++, info++) {113 for (info=device->classes, j=0; j < device->num_classes; j++, info++) {
112 if (info->input_class == KeyClass) {114 if (info->input_class == KeyClass) {
113 DeviceKeyPress(device, key_press_type, event_class);115 DeviceKeyPress(device, key_press_type, event_class);
114 m_eventList.append(event_class);116 m_eventList.append(event_class);
115 DeviceMappingNotify(device, notify_type, event_class);117 DeviceMappingNotify(device, notify_type, event_class);
116 m_eventList.append(event_class);118 m_eventList.append(event_class);
119 }
117 }120 }
118 }121 }
122 XCloseDevice(m_display, device);
119 }123 }
120 XCloseDevice(m_display, device);124 XFreeDeviceList(devices);
121 }125 }
122126
123 XFreeDeviceList(devices);
124
125 if (m_eventList.size() == 0) {127 if (m_eventList.size() == 0) {
126 UQ_WARNING << "No input devices found.";128 UQ_WARNING << "No input devices found.";
127 return false;129 return false;

Subscribers

People subscribed via source and target branches