From b7f69238a1686884ac0cf44fc5d0e12a8f4101f0 Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 22 Jan 2019 17:19:10 -0500 Subject: [PATCH] Fix segfault on several devices --- native/jni/utils/include/utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/native/jni/utils/include/utils.h b/native/jni/utils/include/utils.h index c97c12919..038decbf0 100644 --- a/native/jni/utils/include/utils.h +++ b/native/jni/utils/include/utils.h @@ -16,8 +16,8 @@ #include #include -#define str_contains(s, ss) ((s).find(ss) != string::npos) -#define str_starts(s, ss) ((s).compare(0, strlen(ss), ss) == 0) +#define str_contains(s, ss) ((ss) != nullptr && (s).find(ss) != string::npos) +#define str_starts(s, ss) ((ss) != nullptr && (s).compare(0, strlen(ss), ss) == 0) std::vector file_to_vector(const char *filename); char *strdup2(const char *s, size_t *size = nullptr);