[all-commits] [llvm/llvm-project] 0784e6: [libc] Fix strtok_r crash when src and *saveptr ar...

Alfonso Gregory via All-commits all-commits at lists.llvm.org
Tue Jul 27 14:49:42 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 0784e62c3c4a4aaabdf29f6fa0b5f8f7598a90d4
      https://github.com/llvm/llvm-project/commit/0784e62c3c4a4aaabdf29f6fa0b5f8f7598a90d4
  Author: Alfonso Gregory <gfunni234 at gmail.com>
  Date:   2021-07-27 (Tue, 27 Jul 2021)

  Changed paths:
    M libc/src/string/string_utils.h
    M libc/test/src/string/strtok_r_test.cpp

  Log Message:
  -----------
  [libc] Fix strtok_r crash when src and *saveptr are both nullptr

While working and testing my refactoring of multiple string functions in libc, I came across a bug that needs to be addressed in a patch on its own: src is checked for nullptr and assigned to *saveptr if it is nullptr. However, saveptr is initially nullptr when it comes to reentry. This could cause a problem if both saveptr and src are null; we need to do the check first and return nullptr if both are nullptr.

Reviewed By: sivachandra

Differential Revision: https://reviews.llvm.org/D106885




More information about the All-commits mailing list