about summary refs log tree commit diff
path: root/generator
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2009-05-16 23:20:52 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2009-05-16 23:20:52 +0000
commita795e001646b249b311348df2da83f1bb1444976 (patch)
treec198c7fa0865bda95944cc8a5ae07b60518a7de5 /generator
parentdbdc0476c3ed226ccba2750b09e25887ba12b2bb (diff)
downloadnetpbm-mirror-a795e001646b249b311348df2da83f1bb1444976.tar.gz
netpbm-mirror-a795e001646b249b311348df2da83f1bb1444976.tar.xz
netpbm-mirror-a795e001646b249b311348df2da83f1bb1444976.zip
Release 10.35.64
git-svn-id: http://svn.code.sf.net/p/netpbm/code/stable@923 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'generator')
-rw-r--r--generator/ppmpat.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/generator/ppmpat.c b/generator/ppmpat.c
index f4190d6c..9e2f6d05 100644
--- a/generator/ppmpat.c
+++ b/generator/ppmpat.c
@@ -770,7 +770,7 @@ squig( pixels, cols, rows, maxval )
         x1 = rand() % cols;
         y1 = 0;
         if ( x1 < cols / 2 )
-        xc[0] = rand() % ( x1 * 2 );
+        xc[0] = rand() % ( x1 * 2 + 1);
         else
         xc[0] = cols - 1 - rand() % ( ( cols - x1 ) * 2 );
         yc[0] = rand() % rows;
@@ -788,7 +788,7 @@ squig( pixels, cols, rows, maxval )
         x2 = rand() % cols;
         y2 = 0;
         if ( x2 < cols / 2 )
-        xc[SQ_POINTS - 1] = rand() % ( x2 * 2 );
+        xc[SQ_POINTS - 1] = rand() % ( x2 * 2 + 1);
         else
         xc[SQ_POINTS - 1] = cols - 1 - rand() % ( ( cols - x2 ) * 2 );
         yc[SQ_POINTS - 1] = rand() % rows;
@@ -807,7 +807,7 @@ squig( pixels, cols, rows, maxval )
         y1 = rand() % rows;
         xc[0] = rand() % cols;
         if ( y1 < rows / 2 )
-        yc[0] = rand() % ( y1 * 2 );
+        yc[0] = rand() % ( y1 * 2 + 1);
         else
         yc[0] = rows - 1 - rand() % ( ( rows - y1 ) * 2 );
         x2 = cols - 1;
@@ -825,7 +825,7 @@ squig( pixels, cols, rows, maxval )
         y2 = rand() % rows;
         xc[SQ_POINTS - 1] = rand() % cols;
         if ( y2 < rows / 2 )
-        yc[SQ_POINTS - 1] = rand() % ( y2 * 2 );
+        yc[SQ_POINTS - 1] = rand() % ( y2 * 2 + 1);
         else
         yc[SQ_POINTS - 1] = rows - 1 - rand() % ( ( rows - y2 ) * 2 );
         x1 = cols - 1;
@@ -1006,6 +1006,11 @@ main(int argc, char ** argv) {
     if ( argn != argc )
         pm_usage( usage);
 
+    if (cols < 1)
+        pm_error("width must be at least 1");
+    if (rows < 1)
+        pm_error("height must be at least 1");
+
     srand( (int) ( time( 0 ) ^ getpid( ) ) );
     pixels = ppm_allocarray( cols, rows );