]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
misc/ss: simplify buffer realloc, fix checking realloc failure
authorPhil Sutter <phil@nwl.cc>
Thu, 6 Aug 2015 12:24:33 +0000 (14:24 +0200)
committerStephen Hemminger <shemming@brocade.com>
Wed, 12 Aug 2015 16:23:47 +0000 (09:23 -0700)
Signed-off-by: Phil Sutter <phil@nwl.cc>
misc/ss.c

index d271b9506612d88d7b9225d304066a847748d094..e61fb2ed015f213c8c542d55317c6e9d13d155f2 100644 (file)
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -550,7 +550,7 @@ static int find_entry(unsigned ino, char **buf, int type)
        struct user_ent *p;
        int cnt = 0;
        char *ptr;
-       char **new_buf = buf;
+       char *new_buf;
        int len, new_buf_len;
        int buf_used = 0;
        int buf_len = 0;
@@ -592,12 +592,12 @@ static int find_entry(unsigned ino, char **buf, int type)
 
                        if (len < 0 || len >= buf_len - buf_used) {
                                new_buf_len = buf_len + ENTRY_BUF_SIZE;
-                               *new_buf = realloc(*buf, new_buf_len);
+                               new_buf = realloc(*buf, new_buf_len);
                                if (!new_buf) {
                                        fprintf(stderr, "ss: failed to malloc buffer\n");
                                        abort();
                                }
-                               *buf = *new_buf;
+                               *buf = new_buf;
                                buf_len = new_buf_len;
                                continue;
                        } else {