]> wimlib.net Git - wimlib/blobdiff - src/dentry.c
Avoid passing NULL as memcpy source (undefined behavior)
[wimlib] / src / dentry.c
index ff1a21420f0c2c068d422c1b9645368e96133675..caa3a51b4b86fb0d98e84f103781cc0274499294 100644 (file)
@@ -504,7 +504,8 @@ calculate_dentry_full_path(struct wim_dentry *dentry)
        d = dentry;
        do {
                p -= d->d_name_nbytes / sizeof(utf16lechar);
        d = dentry;
        do {
                p -= d->d_name_nbytes / sizeof(utf16lechar);
-               memcpy(p, d->d_name, d->d_name_nbytes);
+               if (d->d_name_nbytes)
+                       memcpy(p, d->d_name, d->d_name_nbytes);
                *--p = cpu_to_le16(WIM_PATH_SEPARATOR);
                d = d->d_parent;  /* assumes d == d->d_parent for root  */
        } while (!dentry_is_root(d));
                *--p = cpu_to_le16(WIM_PATH_SEPARATOR);
                d = d->d_parent;  /* assumes d == d->d_parent for root  */
        } while (!dentry_is_root(d));