Skip to content

Commit d05ef6e

Browse files
alyyelashramAlyElashram
authored andcommitted
Move inline_strstr.h crash to entrypoints
1 parent 5aa2a30 commit d05ef6e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

libc/src/string/strcasestr.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "src/__support/common.h"
1212
#include "src/__support/ctype_utils.h"
1313
#include "src/__support/macros/config.h"
14+
#include "src/__support/macros/null_check.h"
1415
#include "src/string/memory_utils/inline_strstr.h"
1516

1617
namespace LIBC_NAMESPACE_DECL {
@@ -23,6 +24,9 @@ LLVM_LIBC_FUNCTION(char *, strcasestr,
2324
return LIBC_NAMESPACE::internal::tolower(a) -
2425
LIBC_NAMESPACE::internal::tolower(b);
2526
};
27+
28+
LIBC_CRASH_ON_NULLPTR(haystack);
29+
LIBC_CRASH_ON_NULLPTR(needle);
2630
return inline_strstr(haystack, needle, case_cmp);
2731
}
2832

libc/src/string/strstr.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include "src/__support/common.h"
1212
#include "src/__support/macros/config.h"
13+
#include "src/__support/macros/null_check.h"
1314
#include "src/string/memory_utils/inline_strstr.h"
1415

1516
namespace LIBC_NAMESPACE_DECL {
@@ -18,6 +19,8 @@ namespace LIBC_NAMESPACE_DECL {
1819
// improved upon using well known string matching algorithms.
1920
LLVM_LIBC_FUNCTION(char *, strstr, (const char *haystack, const char *needle)) {
2021
auto comp = [](char l, char r) -> int { return l - r; };
22+
LIBC_CRASH_ON_NULLPTR(haystack);
23+
LIBC_CRASH_ON_NULLPTR(needle);
2124
return inline_strstr(haystack, needle, comp);
2225
}
2326

0 commit comments

Comments
 (0)