[graphics/krita/krita/4.3] plugins/generators/simplexnoise: Fix resource leak

Boudewijn Rempt null at kde.org
Wed Oct 7 13:21:09 BST 2020


Git commit 51c94f89262b95a25599209e6486f396ebb82c65 by Boudewijn Rempt.
Committed on 07/10/2020 at 12:21.
Pushed by rempt into branch 'krita/4.3'.

Fix resource leak

This is why I do not want auto to be used in Krita's code:

auto bla = createSomething();

doesn't warn that you need to delete bla as much as

Bla *bla = createSomething();

because it's invisible that bla is a pointer.

The alternative is that we use smart pointers _everywhere_, which
isn't feasible...

CCMAIL:kimageshop at kde.org
CID:305464
(cherry picked from commit befdf9b4d74389c767cf558c183e9f82a30c0c58)

M  +2    -2    plugins/generators/simplexnoise/simplexnoisegenerator.cpp

https://invent.kde.org/graphics/krita/commit/51c94f89262b95a25599209e6486f396ebb82c65

diff --git a/plugins/generators/simplexnoise/simplexnoisegenerator.cpp b/plugins/generators/simplexnoise/simplexnoisegenerator.cpp
index bf97c34a7c..0562c7f61a 100644
--- a/plugins/generators/simplexnoise/simplexnoisegenerator.cpp
+++ b/plugins/generators/simplexnoise/simplexnoisegenerator.cpp
@@ -65,7 +65,7 @@ void KisSimplexNoiseGenerator::generate(KisProcessingInformation dst, const QSiz
 
     const KoColorSpace *cs = device->colorSpace();
     const KoColorSpace *src = KoColorSpaceRegistry::instance()->colorSpace(GrayAColorModelID.id(), Float32BitsColorDepthID.id(), "Gray-D50-elle-V2-srgbtrc.icc");
-    auto conv = KoColorSpaceRegistry::instance()->createColorConverter(src, cs, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags());
+    KoColorConversionTransformation *conv = KoColorSpaceRegistry::instance()->createColorConverter(src, cs, KoColorConversionTransformation::internalRenderingIntent(), KoColorConversionTransformation::internalConversionFlags());
 
     KisSequentialIteratorProgress it(device, bounds, progressUpdater);
 
@@ -117,7 +117,7 @@ void KisSimplexNoiseGenerator::generate(KisProcessingInformation dst, const QSiz
             conv->transform(c.data(), it.rawData(), 1);
         }
     }
-
+    delete conv;
     open_simplex_noise_free(noise_context);
 }
 


More information about the kimageshop mailing list