From 286647ca8bbf961cb6c3ac65b91c5d870b3af907 Mon Sep 17 00:00:00 2001 From: Roman Shevchenko Date: Fri, 7 Oct 2022 19:39:28 +0200 Subject: [PATCH] [vfs] even stricter input checks in macOS filesystem event helper (IJ-CR-95917) GitOrigin-RevId: dad56b8aa48b8c1ce6a71773d0058947490de332 --- native/fsNotifier/mac/fsnotifier.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/native/fsNotifier/mac/fsnotifier.c b/native/fsNotifier/mac/fsnotifier.c index 62b37f5288a0..604bf2610330 100644 --- a/native/fsNotifier/mac/fsnotifier.c +++ b/native/fsNotifier/mac/fsnotifier.c @@ -119,9 +119,9 @@ static char *read_stdin() { if (result == NULL || feof(stdin)) { return NULL; } - size_t pos = strlen(input_buf) - 1; - if (input_buf[pos] == '\n') { - input_buf[pos] = '\0'; + size_t length = strlen(input_buf); + if (length > 0 && input_buf[length - 1] == '\n') { + input_buf[length - 1] = '\0'; } return input_buf; }