diff --git a/etc/systemd/system-generators/zfs-mount-generator.c b/etc/systemd/system-generators/zfs-mount-generator.c index b07574e72a..ab5dc4d78d 100644 --- a/etc/systemd/system-generators/zfs-mount-generator.c +++ b/etc/systemd/system-generators/zfs-mount-generator.c @@ -224,9 +224,10 @@ line_worker(char *line, const char *cachefile) const char *p_systemd_ignore = strtok_r(NULL, "\t", &toktmp) ?: "-"; /* END CSTYLED */ - const char *pool = dataset; - if ((toktmp = strchr(pool, '/')) != NULL) - pool = strndupa(pool, toktmp - pool); + size_t pool_len = strlen(dataset); + if ((toktmp = strchr(dataset, '/')) != NULL) + pool_len = toktmp - dataset; + const char *pool = *(tofree++) = strndup(dataset, pool_len); if (p_nbmand == NULL) { fprintf(stderr, PROGNAME "[%d]: %s: not enough tokens!\n", @@ -734,7 +735,7 @@ end: if (tofree >= tofree_all + nitems(tofree_all)) { /* * This won't happen as-is: - * we've got 8 slots and allocate 4 things at most. + * we've got 8 slots and allocate 5 things at most. */ fprintf(stderr, PROGNAME "[%d]: %s: need to free %zu > %zu!\n",