[php-src] Issue #20964: UBSAN: fseek() on php://memory with PHP_INT_MIN causes undefined behavior

[email protected] (arshidkv12)
Newsgroups php.bugs
Message-ID <[email protected]>
Issue: https://github.com/php/php-src/issues/20964
Author: arshidkv12

### Description

The following code:

```php
<?php
$stream = fopen('php://memory', 'r+');
$result = fseek($stream, PHP_INT_MIN, SEEK_END);
var_dump($result);```

Resulted in this output:
```
/Users/arshid/Downloads/php-src/main/streams/memory.c:168:45: runtime error: negation of -9223372036854775808 cannot be represented in type 'zend_off_t' (aka 'long long'); cast to an unsigned type to negate this value to itself
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /Users/arshid/Downloads/php-src/main/streams/memory.c:168:45 
[4]    93646 abort      sapi/cli/php z.php
```

But I expected this output instead:
```
-1
```


### PHP Version

```plain
PHP 8.6.0-dev (cli) (built: Jan 18 2026 08:54:52) (NTS DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.6.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.6.0-dev, Copyright (c), by Zend Technologies
```

### Operating System

_No response_
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.