From 47bbe18de2adaf30c0a96cc703fb704f4009392f Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 18 Dec 2011 10:50:55 +0100 Subject: [PATCH] Additional check to return a friendly error when binary STL is not valid --- lib/Slic3r/Config.pm | 2 +- lib/Slic3r/STL.pm | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index 67ce72508c..1a36c9d23b 100644 --- a/lib/Slic3r/Config.pm +++ b/lib/Slic3r/Config.pm @@ -391,7 +391,7 @@ sub validate { } if ($Slic3r::flow_width >= ($Slic3r::nozzle_diameter + $Slic3r::layer_height)) { - # rectangle with shrunk at the ends + # rectangle with semicircles at the ends $Slic3r::min_flow_spacing = $Slic3r::flow_width - $Slic3r::layer_height * (1 - PI/4); } else { # rectangle with shrunk semicircles at the ends diff --git a/lib/Slic3r/STL.pm b/lib/Slic3r/STL.pm index a1562b94d7..7761ce7a59 100644 --- a/lib/Slic3r/STL.pm +++ b/lib/Slic3r/STL.pm @@ -22,6 +22,7 @@ sub read_file { seek $fh, 80, 0; read $fh, my $buf, 4; my $triangle_count = unpack 'L', $buf; + die "STL file seems invalid, could not read facet count\n" if !defined $triangle_count; my $expected_size = + 80 # header + 4 # count