Johannes Sixt <j...@kdbg.org> writes:

> Oh! This is a typo. You meant to check s2 for NULL.
>
> And the declaration for s2 should remain, of course.

Yeah, the moral of the story is don't try to do something you do not
usually do X-<.

The second try (the log message is the same).

I do not know if we want to worry about st_add(1, strlen(s1))
overflow around here, though.

 compat/nedmalloc/nedmalloc.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/compat/nedmalloc/nedmalloc.c b/compat/nedmalloc/nedmalloc.c
index 677d1b2..2d4ef59 100644
--- a/compat/nedmalloc/nedmalloc.c
+++ b/compat/nedmalloc/nedmalloc.c
@@ -955,12 +955,11 @@ void **nedpindependent_comalloc(nedpool *p, size_t elems, 
size_t *sizes, void **
  */
 char *strdup(const char *s1)
 {
-       char *s2 = 0;
-       if (s1) {
-               size_t len = strlen(s1) + 1;
-               s2 = malloc(len);
+       size_t len = strlen(s1) + 1;
+       char *s2 = malloc(len);
+
+       if (s2)
                memcpy(s2, s1, len);
-       }
        return s2;
 }
 #endif
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to