BTW, are you certain that your failure case actually does involve a
NULL, and not an empty string?
regression=# select 'foo' ~* null;?column?
----------
(1 row)
regression=# select 'foo' ~* '';
ERROR: regcomp failed with error empty (sub)expression
This is correct according to the POSIX definition of regular expressions
("A (modern) RE is one or more non-empty branches ...").
regards, tom lane