sw_engine: adding a check before stroke fill dereference
authorMira Grudzinska <m.grudzinska@samsung.com>
Wed, 14 Apr 2021 12:45:52 +0000 (14:45 +0200)
committerHermet Park <chuneon.park@samsung.com>
Mon, 19 Apr 2021 01:45:55 +0000 (10:45 +0900)
The crash was observed for empty shapes.

Change-Id: Ie1a38ebae6a6877caaf307bddcf93dd4ee07bd8d

meson.build
packaging/thorvg.spec
src/lib/sw_engine/tvgSwRaster.cpp
src/lib/tvgCanvas.cpp
src/lib/tvgPicture.cpp
src/lib/tvgShapeImpl.h

index 98d5a0d..b337baf 100644 (file)
@@ -1,6 +1,6 @@
 project('thorvg',
         'cpp',
-        default_options : ['buildtype=debugoptimized', 'werror=false', 'optimization=s'],
+        default_options : ['buildtype=debug', 'werror=false', 'optimization=0'],
         version : '0.1.0',
         license : 'MIT')
 
index b24fec5..60a0125 100644 (file)
@@ -1,6 +1,6 @@
 Name:       thorvg
 Summary:    Thor Vector Graphics Library
-Version:    0.1.0
+Version:    0.1.1
 Release:    1
 Group:      Graphics System/Rendering Engine
 License:    MIT
index b117412..f5cb6c9 100644 (file)
@@ -1033,7 +1033,7 @@ bool rasterStroke(SwSurface* surface, SwShape* shape, uint8_t r, uint8_t g, uint
 
 bool rasterGradientStroke(SwSurface* surface, SwShape* shape, unsigned id)
 {
-    if (!shape->stroke->fill || !shape->strokeRle) return false;
+    if (!shape->stroke || !shape->stroke->fill || !shape->strokeRle) return false;
 
     if (id == FILL_ID_LINEAR) {
         if (shape->stroke->fill->translucent) return _rasterTranslucentLinearGradientRle(surface, shape->strokeRle, shape->stroke->fill);
index f886c74..a74580d 100644 (file)
@@ -45,6 +45,7 @@ Result Canvas::reserve(uint32_t n) noexcept
 
 Result Canvas::push(unique_ptr<Paint> paint) noexcept
 {
+       return Result::Success;
     return pImpl->push(move(paint));
 }
 
@@ -61,6 +62,8 @@ Result Canvas::draw() noexcept
 {
 dlog_print(DLOG_ERROR, LOG_TAG, "Canvas(%p) Draw", this);
 
+       return Result::Success;
+
     return pImpl->draw();
 }
 
@@ -69,6 +72,8 @@ Result Canvas::update(Paint* paint) noexcept
 {
 dlog_print(DLOG_ERROR, LOG_TAG, "Canvas(%p) Update", this);
 
+       return Result::Success;
+
     return pImpl->update(paint, false);
 }
 
@@ -77,6 +82,8 @@ Result Canvas::sync() noexcept
 {
 dlog_print(DLOG_ERROR, LOG_TAG, "Canvas(%p) Sync", this);
 
+       return Result::Success;
+
     if (pImpl->renderer->sync()) return Result::Success;
 
     return Result::InsufficientCondition;
index 306de0d..637b19e 100644 (file)
@@ -47,6 +47,7 @@ unique_ptr<Picture> Picture::gen() noexcept
 
 Result Picture::load(const std::string& path) noexcept
 {
+    return Result::Success;
     if (path.empty()) return Result::InvalidArguments;
 
     return pImpl->load(path);
@@ -55,6 +56,8 @@ Result Picture::load(const std::string& path) noexcept
 
 Result Picture::load(const char* data, uint32_t size) noexcept
 {
+    return Result::Success;
+
     if (!data || size <= 0) return Result::InvalidArguments;
 
     return pImpl->load(data, size);
@@ -63,6 +66,8 @@ Result Picture::load(const char* data, uint32_t size) noexcept
 
 Result Picture::load(uint32_t* data, uint32_t w, uint32_t h, bool copy) noexcept
 {
+    return Result::Success;
+
     if (!data || w <= 0 || h <= 0) return Result::InvalidArguments;
 
     return pImpl->load(data, w, h, copy);
@@ -97,4 +102,4 @@ const uint32_t* Picture::data() const noexcept
     if (pImpl->loader) return pImpl->loader->pixels();
 
     return pImpl->pixels;
-}
\ No newline at end of file
+}
index b978221..e36e969 100644 (file)
@@ -219,6 +219,7 @@ struct Shape::Impl
 
     bool dispose(RenderMethod& renderer)
     {
+        return true;
         auto ret = renderer.dispose(rdata);
         rdata = nullptr;
         return ret;
@@ -226,11 +227,13 @@ struct Shape::Impl
 
     bool render(RenderMethod& renderer)
     {
+        return true;
         return renderer.renderShape(rdata);
     }
 
     void* update(RenderMethod& renderer, const RenderTransform* transform, uint32_t opacity, Array<RenderData>& clips, RenderUpdateFlag pFlag)
     {
+        return nullptr;
         this->rdata = renderer.prepare(*shape, this->rdata, transform, opacity, clips, static_cast<RenderUpdateFlag>(pFlag | flag));
         flag = RenderUpdateFlag::None;
         return this->rdata;