From 529c30fd35476d7fb2e4b56bc6b2907d9f4b8365 Mon Sep 17 00:00:00 2001 From: Kent Date: Wed, 4 Sep 2024 16:29:57 +0800 Subject: [PATCH] Fix issue #181 (should validate cfInode) --- src/efsw/FileWatcherFSEvents.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/efsw/FileWatcherFSEvents.cpp b/src/efsw/FileWatcherFSEvents.cpp index 523d0ed..6ea960d 100644 --- a/src/efsw/FileWatcherFSEvents.cpp +++ b/src/efsw/FileWatcherFSEvents.cpp @@ -84,10 +84,13 @@ void FileWatcherFSEvents::FSEventCallback( ConstFSEventStreamRef streamRef, void CFDictionaryGetValue( pathInfoDict, kFSEventStreamEventExtendedDataPathKey ) ); CFNumberRef cfInode = static_cast( CFDictionaryGetValue( pathInfoDict, kFSEventStreamEventExtendedFileIDKey ) ); - unsigned long inode = 0; - CFNumberGetValue( cfInode, kCFNumberLongType, &inode ); - events.push_back( FSEvent( convertCFStringToStdString( path ), (long)eventFlags[i], - (Uint64)eventIds[i], inode ) ); + + if ( cfInode ) { + unsigned long inode = 0; + CFNumberGetValue( cfInode, kCFNumberLongType, &inode ); + events.push_back( FSEvent( convertCFStringToStdString( path ), (long)eventFlags[i], + (Uint64)eventIds[i], inode ) ); + } } else { events.push_back( FSEvent( std::string( ( (char**)eventPaths )[i] ), (long)eventFlags[i], (Uint64)eventIds[i] ) );