library: the uref functions were insufficiently robust
The earlier attempt at protecting these functions from
already freed memory worked just fine until the memory
was, in fact, reused by the OS. At that point, the ref
count would most likely fail an existing a test for 0.
So this commit will take control of the 'info' pointer
and force it to NULL when a reference count reaches 0.
Plus, since it makes little sense returning an address
that a caller already has, henceforth we will return a
reference count out of the 'ref' and 'unref functions.
Reference(s):
commit 74beff80ff
Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
@@ -74,8 +74,8 @@ int procps_stat_new (struct procps_statinfo **info);
|
||||
int procps_stat_read (struct procps_statinfo *info, const int cpu_only);
|
||||
int procps_stat_read_jiffs (struct procps_statinfo *info);
|
||||
|
||||
struct procps_statinfo *procps_stat_ref (struct procps_statinfo *info);
|
||||
struct procps_statinfo *procps_stat_unref (struct procps_statinfo *info);
|
||||
int procps_stat_ref (struct procps_statinfo *info);
|
||||
int procps_stat_unref (struct procps_statinfo **info);
|
||||
|
||||
jiff procps_stat_get_cpu (struct procps_statinfo *info, enum procps_cpu_item item);
|
||||
int procps_stat_get_cpu_chain (struct procps_statinfo *info, struct procps_cpu_result *item);
|
||||
|
||||
Reference in New Issue
Block a user