]> granicus.if.org Git - procps-ng/commitdiff
library: fix a flaw in one 'new' function, <diskstats>
authorJim Warner <james.warner@comcast.net>
Wed, 19 Aug 2020 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@dropbear.xyz>
Mon, 24 Aug 2020 11:37:52 +0000 (21:37 +1000)
At 'new' time, the major API modules each ensure their
'info' parameter isn't NULL but what it pointed to was
except this single straggler, for some unknown reason.

So, this patch brings him into line with those others.

[ And, without going into the ugly details, this was ]
[ the reason I never experienced an abend originally ]
[ but Craig did. And, though related to stacks mgmt, ]
[ zero initialization was not a factor. Anyway, with ]
[ this patch, everybody would have experienced abend ]
[ under the original (faulty) test_Itemtables logic! ]

Reference(s):
https://www.freelists.org/post/procps/keep-on-patchin,13

Signed-off-by: Jim Warner <james.warner@comcast.net>
proc/diskstats.c

index 3f9ff7c43e79037918f95353b4aafb8267529278..0fb5d58bd964841b3dc42dfdc0206a4fba9372b2 100644 (file)
@@ -733,7 +733,7 @@ PROCPS_EXPORT int procps_diskstats_new (
     if (failed) _Exit(EXIT_FAILURE);
 #endif
 
-    if (info == NULL)
+    if (info == NULL || *info != NULL)
         return -EINVAL;
     if (!(p = calloc(1, sizeof(struct diskstats_info))))
         return -ENOMEM;