all repos — captcha @ 50fb09e8128e07ae0486e239b23e323657e26bda

Go package captcha implements generation and verification of image and audio CAPTCHAs.

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 dmitry@codingrobots.com
Mon, 20 Apr 2015 16:00:42 +0200
commit

50fb09e8128e07ae0486e239b23e323657e26bda

parent

997004be41f20283d2d8a8c0f88146e279d91a39

1 files changed, 3 insertions(+), 0 deletions(-)

jump to
M image.goimage.go

@@ -129,6 +129,9 @@ nw = fw / fh * nh

} // 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