Skip to content

Infinite loop in palettize #213

Description

@Fabus1184

In the palettize function when the PaletteCreationMode Uniform is used, in the corresponding function uniformQuantization when maxCols is less than 8 this causes bitDiv3 to return 0 as at least one element of the tuple (bg, br, bb) which then causes the corresponding list to evaluate to [0, 0 .. 255] which will never terminate.

https://github.com/Twinside/Juicy.Pixels/blob/8b1644255fb5dbe680dff352cf9114a2ce1903ef/src/Codec/Picture/ColorQuant.hs#L157-L173

In my case, this causes the program to use 100% of the CPU filling up the RAM until the system hangs.

If values of less than 8 are not considered valid then this should be at least mentioned in the documentation or there should be a check of some sort.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions