https://bugs.documentfoundation.org/show_bug.cgi?id=98930

            Bug ID: 98930
           Summary: Integer values passed to a C++ function, appear to
                    corrupt stack
           Product: LibreOffice
           Version: 5.0.4.2 release
          Hardware: All
                OS: All
            Status: UNCONFIRMED
          Severity: normal
          Priority: medium
         Component: BASIC
          Assignee: [email protected]
          Reporter: [email protected]

Created attachment 123896
  --> https://bugs.documentfoundation.org/attachment.cgi?id=123896&action=edit
C++ project

May be related to: https://bugs.documentfoundation.org/show_bug.cgi?id=88953

I am using a macro to pass values to an existing third party C++ library that
does further processing. For bug-reporting purposes I made the sample as small
as I could. 

Steps to reproduce: 
1) Build the attached C++ project (the project file is VS2015), place the
resulting DLL in the DLL search path (for example: syswow64 or system32). 
2) Create a LibreOffice macro with the following contents: 
### START SAMPLE ###
REM  *****  BASIC  *****
Declare Function fnlotest Lib "lotest.dll"  (integer, integer, integer,
integer) As Integer
Declare Function fnlotest2 Lib "lotest.dll"  (String, String, String, String,
String) As Integer
declare sub MyMessageBeep Lib "user32.dll" Alias "MessageBeep" (Long)

Sub Main
  MyMessageBeep(5000) ' Test
  Dim szBuffer as string 
  Dim ret as integer 
  szBuffer = Space(512)
  ret = fnlotest(1,2,3,4) ' Expected result: 1+2+3+4 = 10, actual result: 3
  fnlotest2(szBuffer, "foo", "bar", "hello", "world") 
End Sub
### END SAMPLE ###
3) Run the sample and verify the return value of fnlotest(1,2,3,4). It should
add all numbers.


If you run the sample while having the C++ debugger attached, you will see that
the parameters that come through are: 1, 0, 2, 0 instead of 1,2,3,4. Explaining
why we get 3 as a result. 

Interestingly, the second function with string values is fine. 

The third-party DLL uses functions with a signature like: 
foo(int, char*)

Because the stack appears to be corrupted after the first integer passed to a
function, we get an access violation when accessing the char *. 

We tested with older versions, and the last working version is: 4.3.7.2
Currently we are running 5.0.4.2

-- 
You are receiving this mail because:
You are the assignee for the bug.
_______________________________________________
Libreoffice-bugs mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-bugs

Reply via email to