]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
Use reallocarray(3) instead of its pattern
authorAlejandro Colomar <alx@kernel.org>
Sat, 4 Feb 2023 22:20:38 +0000 (23:20 +0100)
committerSerge Hallyn <serge@hallyn.com>
Fri, 24 Feb 2023 02:28:43 +0000 (20:28 -0600)
Signed-off-by: Alejandro Colomar <alx@kernel.org>
libmisc/env.c

index 859dca08a22d6c14e1414fe3acd67a653d7f35a1..eba365ae86a3e2968327a19280f0ea35533bec5b 100644 (file)
@@ -127,15 +127,14 @@ void addenv (const char *string, /*@null@*/const char *value)
 
        if ((newenvc & (NEWENVP_STEP - 1)) == 0) {
                char **__newenvp;
-               size_t newsize;
 
                /*
                 * If the resize operation succeeds we can
                 * happily go on, else print a message.
                 */
 
-               newsize = (newenvc + NEWENVP_STEP) * sizeof (char *);
-               __newenvp = (char **) realloc (newenvp, newsize);
+               __newenvp = (char **) reallocarray (newenvp, newenvc + NEWENVP_STEP,
+                                                   sizeof (char *));
 
                if (NULL != __newenvp) {
                        /*