[libc-commits] [PATCH] D106885: [libc] Fix strtok_r crash when src and *saveptr are both nullptr

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Jul 27 10:17:09 PDT 2021


sivachandra accepted this revision.
sivachandra added a comment.
This revision is now accepted and ready to land.

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



================
Comment at: libc/src/string/string_utils.h:79
+    if (delimiter_set.test(*src)) {
+      *src++ = '\0';
+      break;
----------------
Can we avoid this pattern and do it in two steps:

```
      *src = '\0';
      src++;
```


================
Comment at: libc/test/src/string/strtok_r_test.cpp:89
+  // returned
+  ASSERT_STREQ(__llvm_libc::strtok_r(src, ",", &reserve), nullptr);
+  // And that reserve isn't changed when that happens
----------------
May be add:

```
ASSERT_STREQ(reserver, nullptr);
```

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


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D106885/new/

https://reviews.llvm.org/D106885



More information about the libc-commits mailing list