ofz#47323 suppress Direct-leak

__lsan_default_suppressions works in a local oss-fuzz image but seems
to have no effect when deployed which fits with the report of
https://github.com/google/oss-fuzz/issues/6066

try explicit __lsan_disable/__lsan_enable guards which also works
locally

Change-Id: Ifbfdb9d9ba7014b78b43578c25fca97c3279bc5d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134331
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
diff --git a/vcl/unx/generic/gdi/cairotextrender.cxx b/vcl/unx/generic/gdi/cairotextrender.cxx
index 31c2a73..0be33e9 100644
--- a/vcl/unx/generic/gdi/cairotextrender.cxx
+++ b/vcl/unx/generic/gdi/cairotextrender.cxx
@@ -117,6 +117,14 @@ namespace
    }
}

#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
extern "C"
{
    __attribute__((weak)) void __lsan_disable();
    __attribute__((weak)) void __lsan_enable();
}
#endif

void CairoTextRender::DrawTextLayout(const GenericSalLayout& rLayout, const SalGraphics& rGraphics)
{
    const FreetypeFontInstance& rInstance = static_cast<FreetypeFontInstance&>(rLayout.GetFont());
@@ -178,6 +186,11 @@ void CairoTextRender::DrawTextLayout(const GenericSalLayout& rLayout, const SalG
        return;
    }

#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
    if (__lsan_disable)
        __lsan_disable();
#endif

    if (const cairo_font_options_t* pFontOptions = GetSalInstance()->GetCairoFontOptions())
    {
        const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
@@ -305,6 +318,11 @@ void CairoTextRender::DrawTextLayout(const GenericSalLayout& rLayout, const SalG
    }

    releaseCairoContext(cr);

#if defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
    if (__lsan_enable)
        __lsan_enable();
#endif
}

void FontConfigFontOptions::cairo_font_options_substitute(FcPattern* pPattern)
diff --git a/vcl/workben/svmfuzzer.cxx b/vcl/workben/svmfuzzer.cxx
index f0c129e..53757e3 100644
--- a/vcl/workben/svmfuzzer.cxx
+++ b/vcl/workben/svmfuzzer.cxx
@@ -73,11 +73,6 @@ extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv)
    return 0;
}

extern "C" const char* __lsan_default_suppressions()
{
    return "leak:CairoTextRender::DrawTextLayout\n";
}

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
    SvMemoryStream aStream(const_cast<uint8_t*>(data), size, StreamMode::READ);