pointer dereference
Thanks to Krzysztof WojtaÅ for the test data and fix for this.
+ - an integer division meant that preview scaling to below 1 pixel
+ wide or high (which isn't too useful anyway) was calculating using
+ NaNs on most platforms, and causing an exception on others.
+ Thanks to David Cantrell for producing a backtrace of the crash on
+ his Alpha-NetBSD CPAN test box which made it possible to track this
+ down.
+
Imager 0.69 - 08 Sep 2009
===========
my $noexif; # non-zero to disable EXIF parsing of JPEGs
my $no_gif_set_version; # disable calling EGifSetGifVersion
my $coverage; # build for coverage testing
+my $assert; # build with assertions
GetOptions("help" => \$help,
"enable=s" => \@enable,
"disable=s" => \@disable,
"nolog" => \$NOLOG,
"noexif" => \$noexif,
"nogifsetversion" => \$no_gif_set_version,
- 'coverage' => \$coverage);
+ 'coverage' => \$coverage,
+ "assert|a" => \$assert);
+
+if ($ENV{AUTOMATED_TESTING}) {
+ $assert = 1;
+}
if ($VERBOSE) {
print "Verbose mode\n";
push @defines, [ IMAGER_LOG => 1, "Logging system" ];
}
+if ($assert) {
+ push @defines, [ IM_ASSERT => 1, "im_assert() are effective" ];
+}
+
if ($DEBUG_MALLOC) {
push @defines, [ IMAGER_DEBUG_MALLOC => 1, "Use Imager's DEBUG malloc()" ];
print "Malloc debugging enabled\n";
#endif
+/*
+=item im_assert_fail(file, line, message)
+
+Called when an im_assert() assertion fails.
+
+=cut
+*/
+
+void
+im_assert_fail(char const *file, int line, char const *message) {
+ fprintf(stderr, "Assertion failed line %d file %s: %s\n",
+ line, file, message);
+ exit(EXIT_FAILURE);
+}
+
/*
=back
nxsize = (int) ((float) im->xsize * scx);
if (nxsize < 1) {
nxsize = 1;
- scx = 1 / im->xsize;
+ scx = 1.0 / im->xsize;
}
nysize = (int) ((float) im->ysize * scy);
if (nysize < 1) {
nysize = 1;
- scy = 1 / im->ysize;
+ scy = 1.0 / im->ysize;
}
+ im_assert(scx != 0 && scy != 0);
new_img=i_img_empty_ch(NULL,nxsize,nysize,im->channels);
#define I_LIMIT_8(x) ((x) < 0 ? 0 : (x) > 255 ? 255 : (x))
#define I_LIMIT_DOUBLE(x) ((x) < 0.0 ? 0.0 : (x) > 1.0 ? 1.0 : (x))
+#define I_STRING(x) #x
+
+/* I considered using assert.h here, but perl does it's own thing with
+ assert() and the NDEBUG test is opposite to the direction I prefer */
+#ifdef IM_ASSERT
+extern void im_assert_fail(char const *, int, char const *);
+#define im_assert(x) ((x) ? (void)(0) : im_assert_fail(__FILE__, __LINE__, I_STRING(x)))
+#else
+#define im_assert(x) (void)(0)
+#endif
+
#endif