فهرست منبع

Make sure dotSize is never less than 1.

This fixes panic due in PRNG "invalid argument to Intn" due to
requesting random number with no range (0).
Dmitry Chestnykh 10 سال پیش
والد
کامیت
50fb09e812
1فایلهای تغییر یافته به همراه3 افزوده شده و 0 حذف شده
  1. 3 0
      image.go

+ 3 - 0
image.go

@@ -129,6 +129,9 @@ func (m *Image) calculateSizes(width, height, ncount int) {
 	}
 	// Calculate dot size.
 	m.dotSize = int(nh / fh)
+	if m.dotSize < 1 {
+		m.dotSize = 1
+	}
 	// Save everything, making the actual width smaller by 1 dot to account
 	// for spacing between digits.
 	m.numWidth = int(nw) - m.dotSize