summary refs log tree commit diff stats
path: root/advice.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-02-13 10:01:05 -0500
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-02-13 10:01:05 -0500
commit83927a4d3a3eb3dac54872acdb7947dfda0846dd (patch)
treeebb59b0a316b81de332b3ac1e2de547ae65c2629 /advice.cpp
parent21d28dfaedf8818a73ff817ae31d6267861331ba (diff)
downloadadvice-83927a4d3a3eb3dac54872acdb7947dfda0846dd.tar.gz
advice-83927a4d3a3eb3dac54872acdb7947dfda0846dd.tar.bz2
advice-83927a4d3a3eb3dac54872acdb7947dfda0846dd.zip
Fixed crash when a malformed image is downloaded
Diffstat (limited to 'advice.cpp')
-rw-r--r--advice.cpp21
1 files changed, 11 insertions, 10 deletions
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
180 180
181 std::string imgstr = imgbuf.str(); 181 std::string imgstr = imgbuf.str();
182 img = Magick::Blob(imgstr.c_str(), imgstr.length()); 182 img = Magick::Blob(imgstr.c_str(), imgstr.length());
183 pic.read(img); 183
184 if (pic.rows() == 0) 184 try
185 { 185 {
186 continue; 186 pic.read(img);
187 }
188 187
189 // Too small! 188 if ((pic.rows() > 0) && (pic.columns() >= 400))
190 if (pic.columns() < 400) 189 {
190 std::cout << url << std::endl;
191 found = true;
192 }
193 } catch (const Magick::ErrorOption& e)
191 { 194 {
192 continue; 195 // Occurs when the the data downloaded from the server is malformed
196 std::cout << "Magick: " << e.what() << std::endl;
193 } 197 }
194
195 std::cout << url << std::endl;
196 found = true;
197 } 198 }
198 199
199 if (!found) 200 if (!found)