[Libreoffice-commits] core.git: vcl/unx

Julien Nabet serval2412 at yahoo.fr
Thu Mar 30 09:41:18 UTC 2017


 vcl/unx/generic/window/salframe.cxx |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

New commits:
commit 3d906db0a5542a0d5d4cddf2833075861f6b001e
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Tue Mar 21 21:42:32 2017 +0100

    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 at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

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,


More information about the Libreoffice-commits mailing list