reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit e53ed0c8b09a11e07b760dd7b5a3983d41621c7e
parent 4dd59f3d93777c39bc96b36e222c35321f69ee4a
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Fri,  3 Jan 2020 05:41:58 -0500

fix crash when reading repository indexes without a root element

Diffstat:
Msrc/index.cpp | 2+-
Mtest/index.cpp | 8++++++++
2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/index.cpp b/src/index.cpp @@ -51,7 +51,7 @@ IndexPtr Index::load(const std::string &name, const char *data) TiXmlHandle docHandle(&doc); TiXmlElement *root = doc.RootElement(); - if(strcmp(root->Value(), "index")) + if(!root || strcmp(root->Value(), "index")) throw reapack_error("invalid index"); int version = 0; diff --git a/test/index.cpp b/test/index.cpp @@ -34,6 +34,14 @@ TEST_CASE("load index from raw data", M) { } } +TEST_CASE("no root node", M) { + try { + Index::load({}, R"(<?xml verison="1.0 encoding="utf-8"?>)"); + FAIL(); + } + catch(const reapack_error &) {} +} + TEST_CASE("broken index", M) { UseRootPath root(RIPATH);