X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/4e3c5633b1e74b4f58b95f339cfbbf4cbf21ab3e..769e9f3ea1cbe67d3b98e6db6c956abde2384868:/methods/rred.cc?ds=sidebyside diff --git a/methods/rred.cc b/methods/rred.cc index 85ec30bd5..51af37557 100644 --- a/methods/rred.cc +++ b/methods/rred.cc @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -491,7 +490,11 @@ class Patch { for (ch = filechanges.rbegin(); ch != filechanges.rend(); ++ch) { std::list::reverse_iterator mg_i, mg_e = ch; while (ch->del_cnt == 0 && ch->offset == 0) + { ++ch; + if (unlikely(ch == filechanges.rend())) + return; + } line -= ch->del_cnt; std::string buf; if (ch->add_cnt > 0) { @@ -656,6 +659,11 @@ class RredMethod : public aptMethod { out.Close(); inp.Close(); + if (_error->PendingError() == true) { + std::cerr << "FAILED to read or write files" << std::endl; + return false; + } + if (Debug == true) { std::clog << "rred: finished file patching of " << Path << "." << std::endl; } @@ -695,8 +703,7 @@ int main(int argc, char **argv) Patch patch; if (argc <= 1) { - RredMethod Mth; - return Mth.Run(); + return RredMethod().Run(); } // Usage: rred -t input output diff ...