jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx |    5 ++---
 vcl/source/filter/jpeg/jpegc.cxx                    |    8 +++++++-
 2 files changed, 9 insertions(+), 4 deletions(-)

New commits:
commit fc1d1acd518a9937c2501242dae2af4530b52fe7
Author:     Stephan Bergmann <sberg...@redhat.com>
AuthorDate: Tue May 19 08:57:31 2020 +0200
Commit:     Stephan Bergmann <sberg...@redhat.com>
CommitDate: Tue May 19 09:57:57 2020 +0200

    Avoid UB when calling setjmp
    
    The C standard (and thus by reference also the C++ standard) has very picky
    constraints how invocations of the setjmp macro need to appear to not cause
    undefined behavior.
    
    Change-Id: I09418de340a044e4309261bae9816ca746700858
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94474
    Tested-by: Jenkins
    Reviewed-by: Stephan Bergmann <sberg...@redhat.com>

diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx 
b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
index 7fcd60891263..abe47b567832 100644
--- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
+++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx
@@ -213,11 +213,10 @@ int createJvm(
     g_bInGetJavaVM = 1;
     jint err;
     memset( jmp_jvm_abort, 0, sizeof(jmp_jvm_abort));
-    int jmpval= setjmp( jmp_jvm_abort );
-    /* If jmpval is not "0" then this point was reached by a longjmp in the
+    /* If the setjmp return value is not "0" then this point was reached by a 
longjmp in the
        abort_handler, which was called indirectly by JNI_CreateVM.
     */
-    if( jmpval == 0)
+    if( setjmp( jmp_jvm_abort ) == 0)
     {
         //returns negative number on failure
         err= pCreateJavaVM(pJavaVM, ppEnv, vm_args);
diff --git a/vcl/source/filter/jpeg/jpegc.cxx b/vcl/source/filter/jpeg/jpegc.cxx
index ced814e2fccb..c1fbb535a8e4 100644
--- a/vcl/source/filter/jpeg/jpegc.cxx
+++ b/vcl/source/filter/jpeg/jpegc.cxx
@@ -469,7 +469,13 @@ void Transform(void* pInputStream, void* pOutputStream, 
long nAngle)
     JpegDecompressOwner aDecompressOwner;
     JpegCompressOwner aCompressOwner;
 
-    if (setjmp(aSourceError.setjmp_buffer) || 
setjmp(aDestinationError.setjmp_buffer))
+    if (setjmp(aSourceError.setjmp_buffer))
+    {
+        jpeg_destroy_decompress(&aSourceInfo);
+        jpeg_destroy_compress(&aDestinationInfo);
+        return;
+    }
+    if (setjmp(aDestinationError.setjmp_buffer))
     {
         jpeg_destroy_decompress(&aSourceInfo);
         jpeg_destroy_compress(&aDestinationInfo);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to