Merge lp:~kruk87/glmark2/glmark2-fix-wayland into lp:glmark2/2011.11

Proposed by Rafal Mielniczuk
Status: Merged
Merged at revision: 277
Proposed branch: lp:~kruk87/glmark2/glmark2-fix-wayland
Merge into: lp:glmark2/2011.11
Diff against target: 96 lines (+30/-45)
2 files modified
src/native-state-wayland.cpp (+30/-17)
src/native-state-wayland.h (+0/-28)
To merge this branch: bzr merge lp:~kruk87/glmark2/glmark2-fix-wayland
Reviewer Review Type Date Requested Status
Alexandros Frantzis Approve
Review via email: mp+170145@code.launchpad.net

Description of the change

This small patch checks whether pointers are not null, before dereferencing them.
When glmark is invoked with --help or --list option, those objects arent
allocated and crash glmark in the cleanup routines

To post a comment you must log in.
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/native-state-wayland.cpp'
2--- src/native-state-wayland.cpp 2013-04-29 16:07:13 +0000
3+++ src/native-state-wayland.cpp 2013-06-18 17:17:28 +0000
4@@ -49,23 +49,36 @@
5
6 NativeStateWayland::~NativeStateWayland()
7 {
8- wl_shell_surface_destroy(window_->shell_surface);
9- wl_surface_destroy(window_->surface);
10- wl_egl_window_destroy(window_->native);
11- delete window_;
12-
13- wl_shell_destroy(display_->shell);
14- for (OutputsVector::iterator it = display_->outputs.begin();
15- it != display_->outputs.end(); ++it) {
16-
17- wl_output_destroy((*it)->output);
18- delete *it;
19- }
20- wl_compositor_destroy(display_->compositor);
21- wl_registry_destroy(display_->registry);
22- wl_display_flush(display_->display);
23- wl_display_disconnect(display_->display);
24- delete display_;
25+ if (window_) {
26+ if (window_->shell_surface)
27+ wl_shell_surface_destroy(window_->shell_surface);
28+ if (window_->surface)
29+ wl_surface_destroy(window_->surface);
30+ if (window_->native)
31+ wl_egl_window_destroy(window_->native);
32+ delete window_;
33+ }
34+
35+ if (display_) {
36+ if (display_->shell)
37+ wl_shell_destroy(display_->shell);
38+
39+ for (OutputsVector::iterator it = display_->outputs.begin();
40+ it != display_->outputs.end(); ++it) {
41+
42+ wl_output_destroy((*it)->output);
43+ delete *it;
44+ }
45+ if (display_->compositor)
46+ wl_compositor_destroy(display_->compositor);
47+ if (display_->registry)
48+ wl_registry_destroy(display_->registry);
49+ if (display_->display) {
50+ wl_display_flush(display_->display);
51+ wl_display_disconnect(display_->display);
52+ }
53+ delete display_;
54+ }
55 }
56
57 void
58
59=== modified file 'src/native-state-wayland.h'
60--- src/native-state-wayland.h 2013-04-04 16:53:33 +0000
61+++ src/native-state-wayland.h 2013-06-18 17:17:28 +0000
62@@ -81,34 +81,6 @@
63 shell_surface_handle_popup_done(void *data,
64 struct wl_shell_surface *shell_surface);
65
66- static void
67- keyboard_handle_keymap(void *data, struct wl_keyboard *wl_keyboard,
68- uint32_t format, int32_t fd, uint32_t size);
69-
70- static void
71- keyboard_handle_enter(void *data, struct wl_keyboard *wl_keyboard,
72- uint32_t serial, struct wl_surface *surface,
73- struct wl_array *keys);
74-
75- static void
76- keyboard_handle_leave(void *data, struct wl_keyboard *wl_keyboard,
77- uint32_t serial, struct wl_surface *surface);
78-
79- static void
80- keyboard_handle_key(void *data, struct wl_keyboard *wl_keyboard,
81- uint32_t serial, uint32_t time, uint32_t key,
82- uint32_t state);
83-
84- static void
85- keyboard_handle_modifiers(void *data, struct wl_keyboard *wl_keyboard,
86- uint32_t serial, uint32_t mods_depressed,
87- uint32_t mods_latched, uint32_t mods_locked,
88- uint32_t group);
89-
90- static void
91- seat_handle_capabilities(void *data, struct wl_seat *wl_seat,
92- uint32_t capabilities);
93-
94 struct my_output {
95 wl_output *output;
96 int32_t width, height;

Subscribers

People subscribed via source and target branches