library: protect against possible 'refcount' underflow
In each module employing a priming read at 'new' time, should that read fail, a call to 'unref' will be made. However, there is a hidden dependency that these calls must never occur before the context 'refcount' was set due to the way an 'unref' conditional was constructed. So this commit just ensures that 'unref' will function as expected, even if called with a 'refcount' of zero. Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
@ -901,9 +901,10 @@ PROCPS_EXPORT int procps_stat_unref (
|
||||
{
|
||||
if (info == NULL || *info == NULL)
|
||||
return -EINVAL;
|
||||
|
||||
(*info)->refcount--;
|
||||
|
||||
if ((*info)->refcount == 0) {
|
||||
if ((*info)->refcount < 1) {
|
||||
if ((*info)->cpus.anchor)
|
||||
free((*info)->cpus.anchor);
|
||||
if ((*info)->cpus.result.stacks)
|
||||
|
Reference in New Issue
Block a user