File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -691,14 +691,23 @@ static ssize_t uv__fs_readlink(uv_fs_t* req) {
691
691
692
692
static ssize_t uv__fs_realpath (uv_fs_t * req ) {
693
693
char * buf ;
694
+ char * tmp ;
694
695
695
696
#if defined(_POSIX_VERSION ) && _POSIX_VERSION >= 200809L
696
- buf = realpath (req -> path , NULL );
697
- if (buf == NULL )
697
+ tmp = realpath (req -> path , NULL );
698
+ if (tmp == NULL )
698
699
return -1 ;
700
+ buf = uv__strdup (tmp );
701
+ free (tmp ); /* _Not_ uv__free. */
702
+ if (buf == NULL ) {
703
+ errno = ENOMEM ;
704
+ return -1 ;
705
+ }
699
706
#else
700
707
ssize_t len ;
701
708
709
+ (void )tmp ;
710
+
702
711
len = uv__fs_pathmax_size (req -> path );
703
712
buf = uv__malloc (len + 1 );
704
713
Original file line number Diff line number Diff line change @@ -793,6 +793,7 @@ int uv__cf_loop_signal(uv_loop_t* loop,
793
793
794
794
/* Runs in UV loop to initialize handle */
795
795
int uv__fsevents_init (uv_fs_event_t * handle ) {
796
+ char * buf ;
796
797
int err ;
797
798
uv__cf_loop_state_t * state ;
798
799
@@ -801,9 +802,13 @@ int uv__fsevents_init(uv_fs_event_t* handle) {
801
802
return err ;
802
803
803
804
/* Get absolute path to file */
804
- handle -> realpath = realpath (handle -> path , NULL );
805
- if (handle -> realpath == NULL )
805
+ buf = realpath (handle -> path , NULL );
806
+ if (buf == NULL )
806
807
return UV__ERR (errno );
808
+ handle -> realpath = uv__strdup (buf );
809
+ free (buf ); /* _Not_ uv__free. */
810
+ if (handle -> realpath == NULL )
811
+ return UV_ENOMEM ;
807
812
handle -> realpath_len = strlen (handle -> realpath );
808
813
809
814
/* Initialize event queue */
You can’t perform that action at this time.
0 commit comments