From 83927a4d3a3eb3dac54872acdb7947dfda0846dd Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 13 Feb 2017 10:01:05 -0500 Subject: Fixed crash when a malformed image is downloaded --- advice.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'advice.cpp') diff --git a/advice.cpp b/advice.cpp index 11a5d65..f635a12 100644 --- a/advice.cpp +++ b/advice.cpp @@ -180,20 +180,21 @@ void advice::run() const std::string imgstr = imgbuf.str(); img = Magick::Blob(imgstr.c_str(), imgstr.length()); - pic.read(img); - if (pic.rows() == 0) + + try { - continue; - } + pic.read(img); - // Too small! - if (pic.columns() < 400) + if ((pic.rows() > 0) && (pic.columns() >= 400)) + { + std::cout << url << std::endl; + found = true; + } + } catch (const Magick::ErrorOption& e) { - continue; + // Occurs when the the data downloaded from the server is malformed + std::cout << "Magick: " << e.what() << std::endl; } - - std::cout << url << std::endl; - found = true; } if (!found) -- cgit 1.4.1