This is an archive of the discontinued LLVM Phabricator instance.

[libc] Fix strtok_r crash when src and *saveptr are both nullptr
ClosedPublic

Authored by gAlfonso-bit on Jul 27 2021, 8:51 AM.

Details

Reviewers
sivachandra
gAlfonso-bit
Group Reviewers
Restricted Project
Restricted Project
Commits
rG0784e62c3c4a: [libc] Fix strtok_r crash when src and *saveptr are both nullptr

Diff Detail

Event Timeline

gAlfonso-bit created this revision.Jul 27 2021, 8:51 AM
gAlfonso-bit requested review of this revision.Jul 27 2021, 8:51 AM
This comment was removed by gAlfonso-bit.
This comment was removed by gAlfonso-bit.
This comment was removed by gAlfonso-bit.
sivachandra accepted this revision.Jul 27 2021, 10:17 AM
sivachandra added a subscriber: sivachandra.

Couple of nits inline. I can submit this for you after you update.

libc/src/string/string_utils.h
79

Can we avoid this pattern and do it in two steps:

*src = '\0';
src++;
libc/test/src/string/strtok_r_test.cpp
89

May be add:

ASSERT_STREQ(reserver, nullptr);

May be that is what your intention was below, but not sure.

This revision is now accepted and ready to land.Jul 27 2021, 10:17 AM
This comment was removed by gAlfonso-bit.
This comment was removed by gAlfonso-bit.
gAlfonso-bit marked 2 inline comments as done.
This comment was removed by gAlfonso-bit.
gAlfonso-bit accepted this revision.Jul 27 2021, 11:16 AM
gAlfonso-bit added inline comments.
libc/test/src/string/strtok_r_test.cpp
89

Yeah that is what I meant. Thank you!

gAlfonso-bit resigned from this revision.Jul 27 2021, 11:16 AM

Will submit shortly.

This comment was removed by gAlfonso-bit.
This comment was removed by gAlfonso-bit.
This comment was removed by gAlfonso-bit.

I need your name and email address to attribute this change to you.

This comment was removed by gAlfonso-bit.
gAlfonso-bit edited the summary of this revision. (Show Details)Sep 27 2023, 11:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 27 2023, 11:01 AM
Herald added a subscriber: wangpc. · View Herald Transcript