newsbeuter-2.9-fix-segfault.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. diff --git a/include/poddlthread.h b/include/poddlthread.h
  2. index a10b9e7..cf0f1da 100644
  3. --- a/include/poddlthread.h
  4. +++ b/include/poddlthread.h
  5. @@ -7,6 +7,7 @@
  6. #include <sys/time.h>
  7. #include <time.h>
  8. +#include <memory>
  9. #include <configcontainer.h>
  10. @@ -24,7 +25,7 @@ class poddlthread {
  11. private:
  12. void mkdir_p(const char * file);
  13. download * dl;
  14. - std::ofstream *f;
  15. + std::shared_ptr<std::ofstream> f;
  16. timeval tv1;
  17. timeval tv2;
  18. size_t bytecount;
  19. diff --git a/src/pb_controller.cpp b/src/pb_controller.cpp
  20. index 09b5e89..da8ffcb 100644
  21. --- a/src/pb_controller.cpp
  22. +++ b/src/pb_controller.cpp
  23. @@ -287,6 +287,7 @@ void pb_controller::start_downloads() {
  24. if (it->status() == DL_QUEUED) {
  25. std::thread t {poddlthread(&(*it), cfg)};
  26. --dl2start;
  27. + t.detach();
  28. }
  29. }
  30. }
  31. diff --git a/src/pb_view.cpp b/src/pb_view.cpp
  32. index fb61c72..f3cb478 100644
  33. --- a/src/pb_view.cpp
  34. +++ b/src/pb_view.cpp
  35. @@ -111,6 +111,7 @@ void pb_view::run(bool auto_download) {
  36. if (idx != -1) {
  37. if (ctrl->downloads()[idx].status() != DL_DOWNLOADING) {
  38. std::thread t {poddlthread(&ctrl->downloads()[idx], ctrl->get_cfgcont())};
  39. + t.detach();
  40. }
  41. }
  42. }
  43. diff --git a/src/poddlthread.cpp b/src/poddlthread.cpp
  44. index 583481e..3a1b390 100644
  45. --- a/src/poddlthread.cpp
  46. +++ b/src/poddlthread.cpp
  47. @@ -22,7 +22,6 @@ poddlthread::poddlthread(download * dl_, newsbeuter::configcontainer * c) : dl(d
  48. }
  49. poddlthread::~poddlthread() {
  50. - delete f;
  51. }
  52. void poddlthread::operator()() {