diff options
author | Guillem Jover <guillem@debian.org> | 2018-11-17 20:35:54 +0100 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2019-01-22 13:41:54 +0100 |
commit | e29648778ccd54ff834c3581b460542fdb766d44 (patch) | |
tree | 254d03b751ee9dfee54a8d220855021437a83378 /lib/compat | |
parent | f94d12b62e0747791ece6400f31a15fddc3a2d5b (diff) | |
download | dpkg-e29648778ccd54ff834c3581b460542fdb766d44.tar.gz |
When allocating use the variable instead of the type in sizeof()
This makes it easier to guarantee we use the correct size for the
involved variable.
Diffstat (limited to 'lib/compat')
-rw-r--r-- | lib/compat/scandir.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/compat/scandir.c b/lib/compat/scandir.c index 4765d7dcb..8771de093 100644 --- a/lib/compat/scandir.c +++ b/lib/compat/scandir.c @@ -72,13 +72,13 @@ scandir(const char *dir, struct dirent ***namelist, avail *= 2; else avail = 20; - newlist = realloc(list, avail * sizeof(struct dirent *)); + newlist = realloc(list, avail * sizeof(*newlist)); if (!newlist) return cleanup(d, list, used); list = newlist; } - m = malloc(sizeof(struct dirent) + strlen(e->d_name)); + m = malloc(sizeof(*m) + strlen(e->d_name)); if (!m) return cleanup(d, list, used); *m = *e; @@ -91,7 +91,7 @@ scandir(const char *dir, struct dirent ***namelist, closedir(d); if (list != NULL && cmp != NULL) - qsort(list, used, sizeof(struct dirent *), cmp); + qsort(list, used, sizeof(list[0]), cmp); *namelist = list; |