NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
lib/54131: libedit: declaration of i inside for loop in unescape_string
>Number: 54131
>Category: lib
>Synopsis: libedit: declaration of i inside for loop in unescape_string
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: lib-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Fri Apr 19 22:35:00 +0000 2019
>Originator: Jonathan Perkins
>Release: Sources as of 2019/04/19
>Organization:
Google
>Environment:
>Description:
In filecomplete.c, unescape_string has a declaration inside a for loop. This is incompatible with certain C versions.
The specific line in unescape_string that's an issue is:
for (size_t i = 0; i < length ; i++) {
This was added in revision 53 (http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libedit/filecomplete.c.diff?r1=1.52&r2=1.53&only_with_tag=MAIN&f=h)
This just looked like an oversight to me because most of the code declares outside the for loop. I noticed because we have some code that compiles in a way that hit the issue.
>How-To-Repeat:
gcc -std=c90 -c filecomplete.c -o filecomplete.o
>Fix:
--- old/src/lib/libedit/filecomplete.c
+++ new/src/lib/libedit/filecomplete.c
@@ -193,8 +193,8 @@ unescape_string(const wchar_t *string, s
wchar_t *unescaped = el_malloc(sizeof(*string) * (length + 1));
if (unescaped == NULL)
return NULL;
- size_t j = 0;
- for (size_t i = 0; i < length ; i++) {
+ size_t i = 0, j = 0;
+ for (; i < length ; i++) {
if (string[i] == '\\')
continue;
unescaped[j++] = string[i];
Home |
Main Index |
Thread Index |
Old Index