[php-src] PR #11164: Fix uninitialised variable warning in mbfilter_sjis.c
| From: | nielsdos | Date: | Sat, 29 Apr 2023 22:32:44 +0000 |
| Subject: | [php-src] PR #11164: Fix uninitialised variable warning in mbfilter_sjis.c | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-22408@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/11164
Author: nielsdos
Compiling in release mode with UBSAN gives me the following compiler warning:
```
In function ‘mb_wchar_to_sjismac’:
mbfilter_sjis.c:1419:89: warning: ‘i’ may be used uninitialized [-Wmaybe-uninitialized]
1419 | buf->state = (i << 24) | (index << 16) | (w & 0xFFFF);
| ^~
mbfilter_sjis.c:1398:42: note: ‘i’ was declared here
1398 | for (int i = 0; i < code_tbl_m_len; i++) {
| ^
```
Since the if condition will always be taken after the goto, we can get rid of the warning by moving
the label inside the if.