File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change @@ -387,17 +387,18 @@ if (parser->is_active != 0) return -1;
387387 child->pattern = (char *)" " ;
388388 child->letter = letter;
389389 child->depth = i;
390- child->text = (char *)calloc (1 , strlen (pattern) + 2 );
390+ child->text = (char *)calloc (1 , length + 2 );
391391 /* ENH: Check alloc succeded */
392392 for (j = 0 ; j <= i; j++) child->text [j] = pattern[j];
393393 }
394394 if (i == length - 1 ) {
395395 if (child->is_last == 0 ) {
396396 parser->dict_count ++;
397397 child->is_last = 1 ;
398- child->pattern = (char *)calloc (1 , strlen (pattern) + 2 );
398+ child->pattern = (char *)calloc (1 , length + 2 );
399399 /* ENH: Check alloc succeded */
400- strcpy (child->pattern , pattern);
400+ memcpy (child->pattern , pattern, length);
401+ child->pattern [length] = ' \0 ' ;
401402 }
402403 child->callback = callback;
403404 child->callback_data = data;
You can’t perform that action at this time.
0 commit comments