Skip to contentSkip to conversation

package/libecoli: fix uninitialized width build failure with -Ofast

PATCH In review Yegor Yefremov via buildroot 2 participants 2 messages Nov 11

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/libecoli: fix uninitialized width build failure with -Ofast

libecoli builds with -Werror. With GCC 15 and BR2_OPTIMIZE_FAST, the build fails with:

../src/editline.c: In function 'ec_editline_complete':
../src/editline.c:304:22: error: 'width' may be used uninitialized [-Werror=maybe-uninitialized] ../src/editline.c: In function 'ec_editline_interact':
../src/editline.c:657:22: error: 'width' may be used uninitialized [-Werror=maybe-uninitialized]

This is a real bug: ec_editline_term_size() only writes its width output when both el_get(EL_GETTC) calls succeed, and these two callers neither check its return value nor initialize width beforehand.

Add a patch, submitted upstream, that defaults width to 80 columns, as the other ec_editline_term_size() callers already do.

This issue has been present since commit 5638ee04c8dd ("package/libecoli:
bump version to 0.11.3"), as upstream commit bc90312a4285 ("editline:
split in 2 files"), first released in v0.11.0, dropped the width initialization. It therefore affects 2026.08 and later. The 2026.02.x LTS branch still has libecoli 0.10.1 and is not affected.

Fixes:
https://autobuild.buildroot.org/results/a0a7e17f1a76588932a8a7f8db35a832d540cc69

Fixes 5638ee04c8dddb9ebfb7b047efb574f657e1b052 ("package/libecoli: bump version to 0.11.3")
Assisted-by Claude:claude-opus-5-5
---
 ...-width-before-querying-terminal-size.patch | 56 +++++++++++++++++++
 1 file changed, 56 insertions(+)
 create mode 100644 package/libecoli/0001-editline-initialize-width-before-querying-terminal-size.patch
package/libecoli/0001-editline-initialize-width-before-querying-terminal-size.patch new file +56 -0
new file mode 100644
index 0000000000..e2b833473e
@@ -0,0 +1,56 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Yegor Yefremov <[email protected]>
+Date: Tue, 10 Nov 2026 23:53:35 +0100
+Subject: [PATCH] editline: initialize width before querying terminal size
+
+ec_editline_term_size() only writes the width and height outputs when
+both el_get(EL_GETTC) calls succeed. ec_editline_complete() and
+ec_editline_interact() ignore its return value and do not initialize
+width beforehand, so an indeterminate value is used (clamped to 50..100)
+when the terminal capabilities cannot be retrieved.
+
+With GCC 15 and -Ofast, this is detected and breaks the build because
+of -Werror:
+
+  ../src/editline.c: In function 'ec_editline_complete':
+  ../src/editline.c:304:22: error: 'width' may be used uninitialized [-Werror=maybe-uninitialized]
+  ../src/editline.c: In function 'ec_editline_interact':
+  ../src/editline.c:657:22: error: 'width' may be used uninitialized [-Werror=maybe-uninitialized]
+
+Default width to 80 columns, as the other ec_editline_term_size()
+callers already do.
+
+Link: https://autobuild.buildroot.org/results/a0a7e17f1a76588932a8a7f8db35a832d540cc69
+Fixes: bc90312a4285 ("editline: split in 2 files")
+Upstream: https://github.com/rjarry/libecoli/pull/43
+Assisted-by: Claude:claude-opus-5-5
+Signed-off-by: Yegor Yefremov <[email protected]>
+---
+ src/editline.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/editline.c b/src/editline.c
+index d286135..0751194 100644
+--- a/src/editline.c
++++ b/src/editline.c
+@@ -301,7 +301,7 @@ int ec_editline_complete(struct editline *el, int c)
+ 	struct ec_comp *cmpl = NULL;
+ 	char *append = NULL;
+ 	unsigned int height;
+-	unsigned int width;
++	unsigned int width = 80;
+ 	size_t comp_count;
+ 	void *clientdata;
+ 	char *line = NULL;
+@@ -654,7 +654,7 @@ int ec_editline_interact(
+ 	const struct ec_node *node;
+ 	size_t char_idx = 0;
+ 	unsigned int height;
+-	unsigned int width;
++	unsigned int width = 80;
+ 	char *line = NULL;
+ 	ssize_t n;
+ 	FILE *out;
+-- 
+2.34.1
+
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 23 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Yegor" == Yegor Yefremov via buildroot <[email protected]> writes:

libecoli builds with -Werror. With GCC 15 and BR2_OPTIMIZE_FAST, the build fails with:

../src/editline.c: In function 'ec_editline_complete':
../src/editline.c:304:22: error: 'width' may be used uninitialized [-Werror=maybe-uninitialized] ../src/editline.c: In function 'ec_editline_interact':
../src/editline.c:657:22: error: 'width' may be used uninitialized [-Werror=maybe-uninitialized]

This is a real bug: ec_editline_term_size() only writes its width output when both el_get(EL_GETTC) calls succeed, and these two callers neither check its return value nor initialize width beforehand.

Add a patch, submitted upstream, that defaults width to 80 columns, as the other ec_editline_term_size() callers already do.

This issue has been present since commit 5638ee04c8dd ("package/libecoli:
bump version to 0.11.3"), as upstream commit bc90312a4285 ("editline:
split in 2 files"), first released in v0.11.0, dropped the width initialization. It therefore affects 2026.08 and later. The 2026.02.x LTS branch still has libecoli 0.10.1 and is not affected.

Quoted 6 lines

Fixes:
https://autobuild.buildroot.org/results/a0a7e17f1a76588932a8a7f8db35a832d540cc69

Fixes 5638ee04c8dddb9ebfb7b047efb574f657e1b052 ("package/libecoli: bump version to 0.11.3")
Assisted-by Claude:claude-opus-5-5

Committed, thanks.

Signature · 5 lines
Bye, Peter Korsgaard
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot