Fix a segfault caused by accessing invalid array entries

We are accessing an array in a non-standard way as part of the symbolic handling of regular expressions. This commit adds a guard that prevents the segfault by not accessing invalid values.