From 28d8a5d85158527108a1e5c04a4527eeda7343b1 Mon Sep 17 00:00:00 2001 From: pcpa Date: Tue, 22 May 2012 20:42:32 -0300 Subject: [PATCH] Correct undefined behavior access to out of scope pointer contents. This problem is triggered in gcc 4.7 DCE (dead code elimination). In the Xaw code, the local constant "String" is not guaranteed to have global scope. The problem was found when debugging the reason xedit built with gcc 4.7 would be very unstable, and that happens regardless of using a libXaw built with gcc 4.6. Signed-off-by: pcpa --- src/Text.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Text.c b/src/Text.c index 72387e9..a1ae74a 100644 --- a/src/Text.c +++ b/src/Text.c @@ -3146,7 +3146,7 @@ _XawTextSetSelection(TextWidget ctx, XawTextPosition l, XawTextPosition r, if (nelems == 1 && !strcmp (list[0], "none")) return; if (nelems == 0) { - String defaultSel = "PRIMARY"; + static String defaultSel = "PRIMARY"; list = &defaultSel; nelems = 1; } -- 1.7.10.2