diff --git a/inc/thorvg.h b/inc/thorvg.h index 67833a0d..c6f5e6e2 100644 --- a/inc/thorvg.h +++ b/inc/thorvg.h @@ -988,7 +988,7 @@ public: * @param[in] path A path to the picture file. * * @retval Result::Success When succeed. - * @retval Result::InvalidArguments In case the @p path is empty. + * @retval Result::InvalidArguments In case the @p path is invalid. * @retval Result::NonSupport When trying to load a file with an unknown extension. * @retval Result::Unknown If an error occurs at a later stage. * diff --git a/src/lib/tvgLoaderMgr.cpp b/src/lib/tvgLoaderMgr.cpp index ca5a8100..c55553b5 100644 --- a/src/lib/tvgLoaderMgr.cpp +++ b/src/lib/tvgLoaderMgr.cpp @@ -131,11 +131,14 @@ bool LoaderMgr::term() } -shared_ptr LoaderMgr::loader(const string& path) +shared_ptr LoaderMgr::loader(const string& path, bool* invalid) { + *invalid = false; + if (auto loader = _find(path)) { if (loader->open(path)) return shared_ptr(loader); else delete(loader); + *invalid = true; } return nullptr; } diff --git a/src/lib/tvgLoaderMgr.h b/src/lib/tvgLoaderMgr.h index 849b99f7..665bf2f9 100644 --- a/src/lib/tvgLoaderMgr.h +++ b/src/lib/tvgLoaderMgr.h @@ -30,7 +30,7 @@ struct LoaderMgr { static bool init(); static bool term(); - static shared_ptr loader(const string& path); + static shared_ptr loader(const string& path, bool* invalid); static shared_ptr loader(const char* data, uint32_t size, bool copy); static shared_ptr loader(const uint32_t* data, uint32_t w, uint32_t h, bool copy); }; diff --git a/src/lib/tvgPictureImpl.h b/src/lib/tvgPictureImpl.h index 3a8ec26f..b4e65f0e 100644 --- a/src/lib/tvgPictureImpl.h +++ b/src/lib/tvgPictureImpl.h @@ -167,8 +167,12 @@ struct Picture::Impl Result load(const string& path) { if (loader) loader->close(); - loader = LoaderMgr::loader(path); - if (!loader) return Result::NonSupport; + bool invalid; //Invalid Path + loader = LoaderMgr::loader(path, &invalid); + if (!loader) { + if (invalid) return Result::InvalidArguments; + return Result::NonSupport; + } if (!loader->read()) return Result::Unknown; w = loader->w; h = loader->h;