diff options
author | Julien Nabet <serval2412@yahoo.fr> | 2017-03-21 21:42:32 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2017-03-30 09:40:56 +0000 |
commit | 3d906db0a5542a0d5d4cddf2833075861f6b001e (patch) | |
tree | b7e436608e3f92daf3b9553fe9a07dc4b1945b2e | |
parent | e86d604dc4e12fc9c494484d3f261d91e9d8b01e (diff) |
Fix overflow case returned by XmbLookupString
man of XbmLookupString when XBufferOverflow:
XBufferOverflow The input string to be returned is too
large for the supplied buffer_return. The
required size (for XmbLookupString,
Xutf8LookupString in bytes; for XwcLookup‐
String in characters) is returned as the
value of the function, and the contents of
buffer_return and keysym_return are not
modified. The client should recall the
function with the same event and a buffer
of adequate size to obtain the string.
So in this case retrieve length expected
then call it with +1 for null termination
Change-Id: I8507bb249a411c7e899746e0598f4a055a26fb19
Reviewed-on: https://gerrit.libreoffice.org/35519
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r-- | vcl/unx/generic/window/salframe.cxx | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/vcl/unx/generic/window/salframe.cxx b/vcl/unx/generic/window/salframe.cxx index 3183c0b67167..af37168137bb 100644 --- a/vcl/unx/generic/window/salframe.cxx +++ b/vcl/unx/generic/window/salframe.cxx @@ -3009,7 +3009,10 @@ long X11SalFrame::HandleKeyEvent( XKeyEvent *pEvent ) &nStatus, mpInputContext->GetContext() ); if ( nStatus == XBufferOverflow ) { - nLen *= 2; + // In case of overflow, XmbLookupString (called by GetKeySym) + // returns required size + // TODO : check if +1 is needed for 0 terminator + nLen += 1; pPrintable = static_cast<char*>(alloca( nLen )); nKeySym = pDisplay_->GetKeySym( pEvent, pPrintable, &nLen, &nUnmodifiedKeySym, |