Skip to content

A possible divide by zero bug #2106

@yiyuaner

Description

@yiyuaner

In src/gholder.c, the function set_root_metrics has the following code:

static int
set_root_metrics (GRawDataItem item, GModule module, datatype type, GMetrics ** nmetrics) {
    ...
    uint32_t hits = 0;
    if (map_data (module, item, type, &data, &hits) == 1)
        return 1;
    ...
    metrics->avgts.nts = cumts / hits;

On successful return, the function map_data may set hits to item.hits, and if item.hits is 0, then there is a divide by zero problem. I think this case maybe possible. For example, function parse_raw_data seems to leave the field hits in GRawDataItem as 0.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions