From 8fb85b1f5b43d449e63d9d4d09f96c2ced34023c Mon Sep 17 00:00:00 2001 From: Beniamino Galvani Date: Thu, 4 Oct 2018 09:37:55 +0200 Subject: [PATCH] shared/nm-utils: avoid a coverity warning 1. NetworkManager-1.14.0/shared/nm-utils/nm-shared-utils.c:1242: value_overwrite: Overwriting previous write to "ch" with value from "v". 2. NetworkManager-1.14.0/shared/nm-utils/nm-shared-utils.c:1239: assigned_value: Assigning value from "++str[0]" to "ch" here, but that stored value is overwritten before it can be used. # 1237| if (ch >= '0' && ch <= '7') { # 1238| v = v * 8 + (ch - '0'); # 1239|-> ch = (++str)[0]; # 1240| } # 1241| } Don't assign ch when it is going to be overwritten. (cherry picked from commit e4154895ff7da736ed0021280324aeb718a50408) --- shared/nm-utils/nm-shared-utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/nm-utils/nm-shared-utils.c b/shared/nm-utils/nm-shared-utils.c index 022c065283..4c2e329797 100644 --- a/shared/nm-utils/nm-shared-utils.c +++ b/shared/nm-utils/nm-shared-utils.c @@ -1236,7 +1236,7 @@ nm_utils_buf_utf8safe_unescape (const char *str, gsize *out_len, gpointer *to_fr ch = (++str)[0]; if (ch >= '0' && ch <= '7') { v = v * 8 + (ch - '0'); - ch = (++str)[0]; + ++str; } } ch = v;