Skip to content

Commit 7312244

Browse files
committed
Improve conditions and visibility
1 parent cebfe63 commit 7312244

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

ext/dba/dba.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
646646
char *lock_name;
647647
#ifdef PHP_WIN32
648648
zend_bool restarted = 0;
649+
zend_bool need_creation = 0;
649650
#endif
650651

651652
if (ac < 2) {
@@ -767,10 +768,8 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
767768
break;
768769
case 'c': {
769770
#ifdef PHP_WIN32
770-
php_stream_statbuf ssb;
771-
zend_bool need_creation = 0;
772-
773771
if (hptr->flags & (DBA_NO_APPEND|DBA_CAST_AS_FD)) {
772+
php_stream_statbuf ssb;
774773
need_creation = (SUCCESS != php_stream_stat_path(Z_STRVAL(args[0]), &ssb));
775774
}
776775
#endif
@@ -957,7 +956,7 @@ static void php_dba_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
957956
int flags = fcntl(info->fd, F_GETFL);
958957
fcntl(info->fd, F_SETFL, flags & ~O_APPEND);
959958
#elif defined(PHP_WIN32)
960-
} else if (modenr == DBA_CREAT && !restarted) {
959+
} else if (modenr == DBA_CREAT && need_creation && !restarted) {
961960
zend_bool close_both;
962961

963962
close_both = (info->fp != info->lock.fp);

0 commit comments

Comments
 (0)