From 18fdd09087c7ccc9932d464c7f5939bdf2d6f67a Mon Sep 17 00:00:00 2001 From: Max Christian Pohle Date: Mon, 23 May 2016 01:42:26 +0200 Subject: fixed strlen error --- captcha.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/captcha.c b/captcha.c index 18f7d99..2b86e2e 100644 --- a/captcha.c +++ b/captcha.c @@ -7,10 +7,10 @@ int captcha_print(char* text) gdImagePtr im = gdImageCreateFromPngPtr(file->size, file->data); gdImageColorTransparent(im, gdImageColorAllocate(im, 255, 255, 255)); - char text_width = strlen(text); + char text_width = strlen(text); float letter_width = ((float) gdImageSX(im) / 26.00); - int image_width = letter_width * text_width; + int image_width = letter_width * (text_width - 2); int image_height = gdImageSY(im); gdImagePtr image = gdImageCreateTrueColor(image_width, image_height); @@ -26,7 +26,7 @@ int captcha_print(char* text) } int pos; - for(pos=0; text[pos]!='\0'; pos++) + for(pos=0; pos