<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" id="owaParaStyle"></style>
</head>
<body fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Nice, too bad i didn't find your repository earlier.<span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: 16px; "> </span><br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div id="divRpF520529" style="direction: ltr; "><font face="Tahoma" size="2" color="#000000"><b>From:</b> xcb-bounces+gatis.paeglis=digia.com@lists.freedesktop.org [xcb-bounces+gatis.paeglis=digia.com@lists.freedesktop.org] on behalf of Christoph Reimann [chrr@arcor.de]<br>
<b>Sent:</b> Monday, November 12, 2012 6:31 PM<br>
<b>To:</b> bugzilla-daemon@freedesktop.org<br>
<b>Cc:</b> xcb@lists.freedesktop.org<br>
<b>Subject:</b> Re: [Xcb] [Bug 57022] New: xkb crash when iterating xcb_xkb_get_map() data.<br>
</font><br>
</div>
<div></div>
<div>Hi, I don't have a running XCB version at the moment, but maybe this will help:<br>
As far as I remember, there should be a call to xcb_xkb_get_map_map_unpack. <br>
See below for a function from test code I wrote > two years ago [1]. <br>
Hope that helps, <br>
Christoph<br>
<br>
[1] <a href="http://cgit.freedesktop.org/~chr/check_xkb/tree/xkb_util.c" target="_blank">
http://cgit.freedesktop.org/~chr/check_xkb/tree/xkb_util.c</a><br>
<br>
xcb_xkb_get_map_reply_t *<br>
xcb_xkb_util_get_map(xcb_connection_t      *c, <br>
             xcb_xkb_device_spec_t  device_spec, <br>
             uint16_t               map_components, <br>
             xcb_xkb_get_map_map_t *_aux,<br>
             xcb_generic_error_t  **e) {<br>
  xcb_xkb_get_map_cookie_t cookie;<br>
  xcb_xkb_get_map_reply_t *reply;<br>
  void *buffer; <br>
<br>
  cookie =  xcb_xkb_get_map (c, device_spec, map_components,<br>
                 0, /* partial */<br>
                 0, /* firstType */<br>
                 0, /* nTypes */<br>
                 0, /* firstKeySym */<br>
                 0, /* nKeySyms */<br>
                 0, /* firstKeyAction */<br>
                 0, /* nKeyActions */<br>
                 0, /* firstKeyBehavior */<br>
                 0, /* nKeyBehaviors */<br>
                 0, /* virtualMods */<br>
                 0, /* firstKeyExplicit */<br>
                 0, /* nKeyExplicit */<br>
                 0, /* firstModMapKey */<br>
                 0, /* nModMapKeys */<br>
                 0, /* firstVModMapKey */<br>
                 0  /* nVModMapKeys */);<br>
<br>
  reply = xcb_xkb_get_map_reply (c, cookie, e);<br>
<br>
  if (!(*e)) {<br>
    buffer = xcb_xkb_get_map_map(reply);<br>
    xcb_xkb_get_map_map_unpack (buffer, reply->nTypes, reply->nKeySyms, reply->nKeyActions,<br>
                reply->totalActions, reply->totalKeyBehaviors, reply->nVModMapKeys,<br>
                reply->totalKeyExplicit, reply->totalModMapKeys, reply->totalVModMapKeys,<br>
                reply->present, _aux);<br>
  }<br>
<br>
  return reply;<br>
}<br>
<br>
<br>
<div class="gmail_quote">On 12 November 2012 18:01, <span dir="ltr"><<a href="mailto:bugzilla-daemon@freedesktop.org" target="_blank">bugzilla-daemon@freedesktop.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div>
<table border="1" cellpadding="8" cellspacing="0">
<tbody>
<tr>
<th>Priority</th>
<td>medium </td>
</tr>
<tr>
<th>Bug ID</th>
<td><a title="NEW --- - xkb crash when iterating xcb_xkb_get_map() data." href="https://bugs.freedesktop.org/show_bug.cgi?id=57022" target="_blank">57022</a>
</td>
</tr>
<tr>
<th>Assignee</th>
<td><a href="mailto:xcb@lists.freedesktop.org" target="_blank">xcb@lists.freedesktop.org</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>xkb crash when iterating xcb_xkb_get_map() data. </td>
</tr>
<tr>
<th>QA Contact</th>
<td><a href="mailto:xcb@lists.freedesktop.org" target="_blank">xcb@lists.freedesktop.org</a>
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal </td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified </td>
</tr>
<tr>
<th>OS</th>
<td>All </td>
</tr>
<tr>
<th>Reporter</th>
<td><a href="mailto:gatis.paeglis@digia.com" target="_blank">gatis.paeglis@digia.com</a>
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Other </td>
</tr>
<tr>
<th>Status</th>
<td>NEW </td>
</tr>
<tr>
<th>Version</th>
<td>unspecified </td>
</tr>
<tr>
<th>Component</th>
<td>Library </td>
</tr>
<tr>
<th>Product</th>
<td>XCB </td>
</tr>
</tbody>
</table>
<p></p>
<div>
<pre>Fallowing example always crashes when trying to read data returned from
xcb_xkb_get_map(). Tested with both real and virtual modifiers, unable to read
keycodes.

    xcb_xkb_get_map_cookie_t map_cookie;
    xcb_xkb_get_map_reply_t *map_reply;
    xcb_generic_error_t *map_error = 0;

    map_cookie = xcb_xkb_get_map(xcb_connection(),
                                 XCB_XKB_ID_USE_CORE_KBD,
                                 XCB_XKB_MAP_PART_VIRTUAL_MOD_MAP |
                                 XCB_XKB_MAP_PART_KEY_TYPES |
                                 XCB_XKB_MAP_PART_KEY_SYMS |
                                 XCB_XKB_MAP_PART_EXPLICIT_COMPONENTS |
                                 XCB_XKB_MAP_PART_KEY_ACTIONS |
                                 XCB_XKB_MAP_PART_KEY_BEHAVIORS |
                                 XCB_XKB_MAP_PART_VIRTUAL_MODS |
                                 XCB_XKB_MAP_PART_MODIFIER_MAP,
                                 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0); // hmm

    map_reply = xcb_xkb_get_map_reply(xcb_connection(), map_cookie,
&map_error);
    if (map_error) {
        free(map_error);
        return;
    }

    const xcb_xkb_get_map_map_t *map = (xcb_xkb_get_map_map_t
*)xcb_xkb_get_map_map(map_reply);


    xcb_xkb_key_v_mod_map_iterator_t iter =
xcb_xkb_get_map_map_vmodmap_rtrn_iterator(map_reply, map);
    xcb_keycode_t key = 0;
    while (iter.rem) {
        if (iter.data) {
            key = iter.data->keycode; // <----- CRASH
            xcb_xkb_key_v_mod_map_next(&iter);
        }
    }</pre>
</div>
<p></p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the QA Contact for the bug. </li><li>You are the assignee for the bug. </li></ul>
</div>
<br>
_______________________________________________<br>
Xcb mailing list<br>
<a href="mailto:Xcb@lists.freedesktop.org" target="_blank">Xcb@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/xcb" target="_blank">http://lists.freedesktop.org/mailman/listinfo/xcb</a><br>
</blockquote>
</div>
<br>
</div>
</div>
</div>
</body>
</html>