debug/hist.c Access .. results in a dereference of a null

Maybe this is only a bug if a call to HistAdd() is made before HistCreate().

SonarCloud
debug/hist.c:147 Access to field 'hi_cum' results in a dereference of a null pointer (loaded from variable 'h')
https://sonarcloud.io/project/issues?open=AZJB17kdNGfDNup0RkzB&id=dlmiles_magic
This commit is contained in:
Darryl L. Miles 2024-09-29 23:00:00 +01:00 committed by Tim Edwards
parent 60fe6427da
commit 8e0f34c6f1
1 changed files with 3 additions and 1 deletions

View File

@ -141,8 +141,10 @@ HistAdd(name, ptrKeys, value)
{
Histogram * h;
if((h=histFind(name, ptrKeys))==(Histogram *) NULL)
if((h=histFind(name, ptrKeys))==(Histogram *) NULL) {
HistCreate(name, ptrKeys, 0, 20, 10);
h=histFind(name, ptrKeys);
}
h->hi_cum+=value;
if(value < h->hi_lo)