Skip to content

Commit

Permalink
Change impossible condition into assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsdos authored Dec 27, 2024
1 parent 71dfa93 commit accf957
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions ext/spl/spl_directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -1596,13 +1596,12 @@ PHP_METHOD(GlobIterator, count)
RETURN_THROWS();
}

if (spl_intern_is_glob(intern)) {
RETURN_LONG(php_glob_stream_get_count(intern->u.dir.dirp, NULL));
} else {
/* This can happen by abusing destructors. */
/* TODO: relax this from E_ERROR to an exception */
php_error_docref(NULL, E_ERROR, "GlobIterator lost glob state");
}
/* The spl_filesystem_object_get_method_check() function is called prior to calling this function.
* Therefore, the directory entry cannot be NULL. However, if it is not NULL, then it must be a glob iterator
* by construction. */
ZEND_ASSERT(spl_intern_is_glob(intern));

RETURN_LONG(php_glob_stream_get_count(intern->u.dir.dirp, NULL));
}
/* }}} */
#endif /* HAVE_GLOB */
Expand Down

0 comments on commit accf957

Please sign in to comment.