Fix gcc -fsanitize=nonnull-attribute issues