diff -u lib_mysqludf_preg-1.0.1/lib_mysqludf_preg_position.c mysql-preg/lib_mysqludf_preg_position.c --- lib_mysqludf_preg-1.0.1/lib_mysqludf_preg_position.c 2009-02-15 23:21:41.000000000 +0000 +++ mysql-preg/lib_mysqludf_preg_position.c 2012-09-04 13:43:33.000000000 +0000 @@ -246,7 +246,7 @@ groupnum = pregGetGroupNum( re , args , 2 ) ; // If groupnum found, get the offset - if( groupnum >= 0 && groupnum < oveccount ) + if( groupnum >= 0 && groupnum < (oveccount/3) ) { // ovec is in pairs of starting and ending offsets. (ie. // ovec[0] is start of whole match, ovec[1] is end of whole