From f5937adbcb65eb1cbda9872db80894b133141eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthieu=20Berthom=C3=A9?= Date: Sun, 9 Oct 2022 18:49:40 +0200 Subject: [PATCH] return ENOTSUP when branches empty after update --- src/branches.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/branches.cpp b/src/branches.cpp index 99a0eaf8..c8765d29 100644 --- a/src/branches.cpp +++ b/src/branches.cpp @@ -205,6 +205,9 @@ namespace l Branches::Impl tmp_branches(branches_->minfreespace()); str::split(str_,':',&paths); + if (paths.empty()) + return -ENOTSUP; + for(auto &path : paths) { rv = l::parse(path,&tmp_branches); @@ -269,6 +272,9 @@ namespace l int erase_begin(Branches::Impl *branches_) { + if (branches_->size() <= 1) + return -ENOTSUP; + branches_->erase(branches_->begin()); return 0; @@ -278,6 +284,9 @@ namespace l int erase_end(Branches::Impl *branches_) { + if (branches_->size() <= 1) + return -ENOTSUP; + branches_->pop_back(); return 0; @@ -299,6 +308,8 @@ namespace l { match = ::fnmatch(pi->c_str(),i->path.c_str(),0); } + if (match == 0 && branches_->size() == 1) + return -ENOTSUP; i = ((match == 0) ? branches_->erase(i) : (i+1)); }