aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Sijmen J. Mulder <ik@sjmulder.nl>2020-06-24 01:05:42 +0200
committerGravatar GitHub <noreply@github.com>2020-06-24 04:35:42 +0530
commit235eb296149ff1d16accadc37c52542b7f18ef2d (patch)
treeefcd7dee312154232e3b62d58ead9f6a6535fa35 /src
parent3686ef756a3cde8d58d8c9d8dac48863846ac9dd (diff)
downloadnnn-235eb296149ff1d16accadc37c52542b7f18ef2d.tar.gz
Fix check when char is unsigned (#665)
If char is unsigned (as on ARM) subtracting a larger number would result in a wrap around, not a negative value. src/nnn.c: In function 'readpipe': src/nnn.c:4325:11: warning: comparison is always false due to limited range of data type [-Wtype-limits] if (ctx < 0 || ctx > CTX_MAX) ^
Diffstat (limited to 'src')
-rw-r--r--src/nnn.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/nnn.c b/src/nnn.c
index a8f82ed..ef20b13 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -4326,9 +4326,11 @@ static void readpipe(int fd, char **path, char **lastname, char **lastdir)
if (g_buf[0] == '+')
ctx = (char)(get_free_ctx() + 1);
+ else if (g_buf[0] < '0')
+ return;
else {
ctx = g_buf[0] - '0';
- if (ctx < 0 || ctx > CTX_MAX)
+ if (ctx > CTX_MAX)
return;
}