Skip to content

An Infinite loop in the time formatter #367

Closed
@danpla

Description

@danpla

+ has higher precedence than ?:, so this line will not expand the buffer, giving an infinite loop with long strftime results. It should be:

buffer.reserve(buffer.capacity() + (size > MIN_GROWTH ? size : MIN_GROWTH));

Simple test:

    std::string s = "{:";
    for (int i = 0; i < 30; ++i)
        s += "%c";
    s += "}\n";

    auto t = std::time(nullptr);
    fmt::print(s, *std::localtime(&t));

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions