Skip to content

putText fails with empty std::string #5451

@dorian3d

Description

@dorian3d

putText throws a segmentation fault when an empty std::string is passed as the text argument. It doesn't happen with an "empty" char array:

cv::Mat im(640, 480, CV_8UC3);
std::cout << "a" << std::endl;
cv::putText(im, "", cv::Point(10, 30), cv::FONT_HERSHEY_PLAIN,
            1., cv::Scalar(255, 255, 255));
std::cout << "b" << std::endl;
cv::putText(im, std::string(""), cv::Point(10, 30), cv::FONT_HERSHEY_PLAIN,
            1., cv::Scalar(255, 255, 255));
std::cout << "c" << std::endl;

Output:

a
b
Segmentation fault (core dumped)

OpenCV version 3.0.0. GCC g++ (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4. Linux 3.16.0-50-generic x86_64.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions