[CLEANUP] add a few checks for functions return values
Markus Elfring suggested adding a few checks which were missing
after a bunch of getsockopt() and 2 strdup(). While those are
unlikely to fail where they are used, it makes the code cleaner.
diff --git a/src/standard.c b/src/standard.c
index 64357a2..a32267b 100644
--- a/src/standard.c
+++ b/src/standard.c
@@ -96,6 +96,8 @@
memset(&sa, 0, sizeof(sa));
str = strdup(str);
+ if (str == NULL)
+ goto out_nofree;
if ((c = strrchr(str,':')) != NULL) {
*c++ = '\0';
@@ -120,6 +122,7 @@
sa.sin_family = AF_INET;
free(str);
+ out_nofree:
return &sa;
}
@@ -137,6 +140,8 @@
memset(mask, 0, sizeof(*mask));
memset(addr, 0, sizeof(*addr));
str = strdup(str);
+ if (str == NULL)
+ return 0;
if ((c = strrchr(str, '/')) != NULL) {
*c++ = '\0';