Skip to content

Infinite loop in enhanceContrastLinearly #3

@LukeDeWaal

Description

@LukeDeWaal

Line 96 in imgproc.cpp there is a loop:

for (first = 0; first < src_hist->range; first++)

which will run forever for some images while not for others. Why it fails only with certain images is unknown.
It fails with the attached image as an example.

My best guess is that this is caused by the fact that the variable first is an unsigned char, and src_hist->range is set to 256, so when updating the variable in the for loop the unsigned char loops back to 0, causing an infinite loop.

A possible fix would be to set the looping condition to first < src_hist->range-1 instead.

0051x2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions