From efa0035fe615f3463d74e0d767b697d2a1ba9ac4 Mon Sep 17 00:00:00 2001 From: Hermet Park Date: Thu, 3 Jun 2021 20:48:02 +0900 Subject: [PATCH] common initializer: correct the result value. When memory is not allocated successully, it must return the FailedAllocation as the return value. Previous initializer wrongly returns the value that case, this corrects it. --- inc/thorvg.h | 2 +- src/lib/tvgInitializer.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/inc/thorvg.h b/inc/thorvg.h index 3a53d0a3..1ee76984 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -1272,7 +1272,7 @@ public: * @param[in] threads The number of additional threads. Zero indicates only the main thread is to be used. * * @retval Result::Success When succeed. - * @retval Result::InsufficientCondition An internal error possibly with memory allocation. + * @retval Result::FailedAllocation An internal error possibly with memory allocation. * @retval Result::InvalidArguments If unknown engine type chosen. * @retval Result::NonSupport In case the engine type is not supported on the system. * @retval Result::Unknown Others. diff --git a/src/lib/tvgInitializer.cpp b/src/lib/tvgInitializer.cpp index ca952c47..c36b02f3 100644 --- a/src/lib/tvgInitializer.cpp +++ b/src/lib/tvgInitializer.cpp @@ -49,12 +49,12 @@ Result Initializer::init(CanvasEngine engine, uint32_t threads) noexcept if (static_cast(engine) & static_cast(CanvasEngine::Sw)) { #ifdef THORVG_SW_RASTER_SUPPORT - if (!SwRenderer::init(threads)) return Result::InsufficientCondition; + if (!SwRenderer::init(threads)) return Result::FailedAllocation; nonSupport = false; #endif } else if (static_cast(engine) & static_cast(CanvasEngine::Gl)) { #ifdef THORVG_GL_RASTER_SUPPORT - if (!GlRenderer::init(threads)) return Result::InsufficientCondition; + if (!GlRenderer::init(threads)) return Result::FailedAllocation; nonSupport = false; #endif } else {