diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index c0bf9d067d..7338b9d72c 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -4871,7 +4871,9 @@ zpool_load_compat(const char *compat, boolean_t *features, char *report, line != NULL; line = strtok_r(NULL, "\n", &ls)) { /* discard comments */ - *(strchrnul(line, '#')) = '\0'; + char *r = strchr(line, '#'); + if (r != NULL) + *r = '\0'; for (word = strtok_r(line, ", \t", &ws); word != NULL;