From 33eea2592690a59bf4d103133fa158b8f18b8bb7 Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 21 May 2014 20:30:35 +0800 Subject: [PATCH] check length --- src/str.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/str.c b/src/str.c index c83cd92..673eee4 100644 --- a/src/str.c +++ b/src/str.c @@ -41,15 +41,15 @@ char * inside_slug(char * needle, int needle_len, char *offset) { char * s1 = offset; char * s2 = offset; - while( s1 >= needle ) { + while( s1 >= needle && (s1 - needle < needle_len) ) { if ( *s1 == '{' ) { break; } s1--; } - char *end = needle+ needle_len; - while( s2 < end ) { + char * end = needle + needle_len; + while( (s2 + 1) < end ) { if ( *s2 == '}' ) { break; }