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:
Jim Warner
2015-06-30 00:00:00 -05:00
committed by Craig Small
parent ff852103f8
commit faf6d4dc93
8 changed files with 54 additions and 48 deletions

View File

@ -106,7 +106,7 @@ static void get_boot_time(void)
xerrx(EXIT_FAILURE,
_("Unable to read system stat information"));
boot_time = procps_stat_get_sys(sys_info, PROCPS_STAT_BTIME);
procps_stat_unref(sys_info);
procps_stat_unref(&sys_info);
}
static void get_memory_total()
@ -119,7 +119,7 @@ static void get_memory_total()
xerrx(EXIT_FAILURE,
_("Unable to read meminfo information"));
memory_total = procps_meminfo_get(mem_info, PROCPS_MEM_TOTAL);
procps_meminfo_unref(mem_info);
procps_meminfo_unref(&mem_info);
}
/*************************************************************************/