Mercurial > vim
comparison src/filepath.c @ 33578:0c36813bed95
patch 9.0.2033: gcc overflow-warning for f_resolve
Commit: https://github.com/vim/vim/commit/215c3261a25f7a99e8711a3b3c6158119c6aea9e
Author: Ken Takata <kentkt@csc.jp>
Date: Mon Oct 16 09:57:43 2023 +0200
patch 9.0.2033: gcc overflow-warning for f_resolve
Problem: gcc overflow-warning for f_resolve
Solution: use pointer p instead of pointer q[-1]
Suppress the following warning:
```
filepath.c: In function ?f_resolve?:
filepath.c:2162:27: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
2162 | q[-1] = NUL;
```
Closes: #13352
closes: #13353
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Ken Takata <kentkt@csc.jp>
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 16 Oct 2023 10:00:11 +0200 |
parents | 705d0e1329a5 |
children | 1629cc65d78d |
comparison
equal
deleted
inserted
replaced
33577:d6dde6229b36 | 33578:0c36813bed95 |
---|---|
2157 | 2157 |
2158 q = gettail(p); | 2158 q = gettail(p); |
2159 if (q > p && *q == NUL) | 2159 if (q > p && *q == NUL) |
2160 { | 2160 { |
2161 // Ignore trailing path separator. | 2161 // Ignore trailing path separator. |
2162 q[-1] = NUL; | 2162 p[q - p - 1] = NUL; |
2163 q = gettail(p); | 2163 q = gettail(p); |
2164 } | 2164 } |
2165 if (q > p && !mch_isFullName(buf)) | 2165 if (q > p && !mch_isFullName(buf)) |
2166 { | 2166 { |
2167 // symlink is relative to directory of argument | 2167 // symlink is relative to directory of argument |