getopt: fix null pointer arithmetic ub