| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | #ifdef HAVE_XORG_CONFIG_H1 |
| 24 | #include <xorg-config.h> |
| 25 | #endif |
| 26 | |
| 27 | #include "present_priv.h" |
| 28 | |
| 29 | |
| 30 | |
| 31 | |
| 32 | |
| 33 | |
| 34 | void |
| 35 | present_clear_window_notifies(WindowPtr window) |
| 36 | { |
| 37 | present_notify_ptr notify; |
| 38 | present_window_priv_ptr window_priv = present_window_priv(window); |
| 39 | |
| 40 | if (!window_priv) |
| 41 | return; |
| 42 | |
| 43 | xorg_list_for_each_entry(notify, &window_priv->notifies, window_list)for (notify = (typeof(*notify) *)((char *)((&window_priv-> notifies)->next) - __builtin_offsetof(typeof(*notify), window_list )); ¬ify->window_list != (&window_priv->notifies ); notify = (typeof(*notify) *)((char *)(notify->window_list .next) - __builtin_offsetof(typeof(*notify), window_list))) { |
| 44 | notify->window = NULL((void*)0); |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | void |
| 53 | present_free_window_notify(present_notify_ptr notify) |
| 54 | { |
| 55 | xorg_list_del(¬ify->window_list); |
| 56 | } |
| 57 | |
| 58 | |
| 59 | |
| 60 | |
| 61 | |
| 62 | int |
| 63 | present_add_window_notify(present_notify_ptr notify) |
| 64 | { |
| 65 | WindowPtr window = notify->window; |
| 66 | present_window_priv_ptr window_priv = present_get_window_priv(window, TRUE1); |
| 67 | |
| 68 | if (!window_priv) |
| 69 | return BadAlloc11; |
| 70 | |
| 71 | xorg_list_add(¬ify->window_list, &window_priv->notifies); |
| 72 | return Success0; |
| 73 | } |
| 74 | |
| 75 | int |
| 76 | present_create_notifies(ClientPtr client, int num_notifies, xPresentNotify *x_notifies, present_notify_ptr *p_notifies) |
| 77 | { |
| 78 | present_notify_ptr notifies; |
| 79 | int i; |
| 80 | int added = 0; |
| 81 | int status; |
| 82 | |
| 83 | notifies = calloc (num_notifies, sizeof (present_notify_rec)); |
| |
| 84 | if (!notifies) |
| 2 | | Assuming 'notifies' is non-null | |
|
| |
| 85 | return BadAlloc11; |
| 86 | |
| 87 | for (i = 0; i < num_notifies; i++) { |
| 4 | | Assuming 'i' is >= 'num_notifies' | |
|
| 5 | | Loop condition is false. Execution continues on line 99 | |
|
| 88 | status = dixLookupWindow(¬ifies[i].window, x_notifies[i].window, client, DixGetAttrAccess(1<<4)); |
| 89 | if (status != Success0) |
| 90 | goto bail; |
| 91 | |
| 92 | notifies[i].serial = x_notifies[i].serial; |
| 93 | status = present_add_window_notify(¬ifies[i]); |
| 94 | if (status != Success0) |
| 95 | goto bail; |
| 96 | |
| 97 | added = i; |
| 98 | } |
| 99 | return Success0; |
| 6 | | Within the expansion of the macro 'Success':
|
a | Potential leak of memory pointed to by 'notifies' |
|
| 100 | |
| 101 | bail: |
| 102 | present_destroy_notifies(notifies, added); |
| 103 | return status; |
| 104 | } |
| 105 | |
| 106 | void |
| 107 | present_destroy_notifies(present_notify_ptr notifies, int num_notifies) |
| 108 | { |
| 109 | int i; |
| 110 | for (i = 0; i < num_notifies; i++) |
| 111 | present_free_window_notify(¬ifies[i]); |
| 112 | |
| 113 | free(notifies); |
| 114 | } |