`maxlen` probably is only used to specifiy a prefix of `str`, so I would assume `maxlen <= STRLEN(str)`.

If a bigger value would be used for `maxlen`, you could get problems further down in `str_to_reg`, which uses `len` (`== maxlen, maxlen > STRLEN(str)`) to access characters in `str`.