@@ -450,7 +450,7 @@ restore_directories(const char *pg_data_dir, const char *backup_dir)
450450
451451 /* Extract link name from relative path */
452452 link_sep = first_dir_separator (link_ptr );
453- if (link_sep )
453+ if (link_sep != NULL )
454454 {
455455 int len = link_sep - link_ptr ;
456456 strncpy (link_name , link_ptr , len );
@@ -484,8 +484,12 @@ restore_directories(const char *pg_data_dir, const char *backup_dir)
484484 */
485485 if (strcmp (dir_created , linked_path ) == 0 )
486486 {
487- /* Create rest of directories */
488- if (link_sep && (link_sep + 1 ))
487+ /*
488+ * Create rest of directories.
489+ * First check is there any directory name after
490+ * separator.
491+ */
492+ if (link_sep != NULL && * (link_sep + 1 ) != '\0' )
489493 goto create_directory ;
490494 else
491495 continue ;
@@ -528,8 +532,11 @@ restore_directories(const char *pg_data_dir, const char *backup_dir)
528532 /* Save linked directory */
529533 set_tablespace_created (link_name , linked_path );
530534
531- /* Create rest of directories */
532- if (link_sep && (link_sep + 1 ))
535+ /*
536+ * Create rest of directories.
537+ * First check is there any directory name after separator.
538+ */
539+ if (link_sep != NULL && * (link_sep + 1 ) != '\0' )
533540 goto create_directory ;
534541
535542 continue ;
0 commit comments