]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
lib/: Use REALLOCF() instead of its pattern
authorAlejandro Colomar <alx@kernel.org>
Sun, 12 May 2024 23:18:48 +0000 (01:18 +0200)
committerSerge Hallyn <serge@hallyn.com>
Tue, 2 Jul 2024 02:40:11 +0000 (21:40 -0500)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
lib/commonio.c
lib/subordinateio.c

index aa6d8c872369adeaa1d222acd71e2debbdfb1a96..1a6f1db5b2325ba2df7a784745fedc80c3a41ab4 100644 (file)
@@ -648,11 +648,10 @@ int commonio_open (struct commonio_db *db, int mode)
                        size_t len;
 
                        buflen += BUFLEN;
-                       cp = REALLOC(buf, buflen, char);
-                       if (NULL == cp) {
-                               goto cleanup_buf;
+                       buf = REALLOCF(buf, buflen, char);
+                       if (NULL == buf) {
+                               goto cleanup_ENOMEM;
                        }
-                       buf = cp;
                        len = strlen (buf);
                        if (db->ops->fgets (buf + len,
                                            (int) (buflen - len),
index a4e114de31f11d2086b3a5a17a888b5f793d3c71..9dd7702ab0ef0920edf1d35442fad916c8fa290a 100644 (file)
@@ -929,9 +929,8 @@ static bool all_digits(const char *str)
 
 static int append_uids(uid_t **uids, const char *owner, int n)
 {
-       uid_t owner_uid;
-       uid_t *ret;
-       int i;
+       int    i;
+       uid_t  owner_uid;
 
        if (all_digits(owner)) {
                i = sscanf(owner, "%d", &owner_uid);
@@ -957,13 +956,11 @@ static int append_uids(uid_t **uids, const char *owner, int n)
                        return n;
        }
 
-       ret = REALLOC(*uids, n + 1, uid_t);
-       if (!ret) {
-               free(*uids);
+       *uids = REALLOCF(*uids, n + 1, uid_t);
+       if (!*uids)
                return -1;
-       }
-       ret[n] = owner_uid;
-       *uids = ret;
+
+       (*uids)[n] = owner_uid;
        return n+1;
 }