summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpcpa <paulo.cesar.pereira.de.andrade@gmail.com>2012-05-22 20:42:32 -0300
committerAlan Coopersmith <alan.coopersmith@oracle.com>2012-05-22 19:07:20 -0700
commit11c3a104141e1a4946ad949dfb5514df0b66a031 (patch)
tree4640b903bcd7c99badcee34421d647e176488b76
parentb16cc35e551860a0bff54c47b33317536ddeae52 (diff)
downloadxorg-lib-libXaw-11c3a104141e1a4946ad949dfb5514df0b66a031.tar.gz
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 <paulo.cesar.pereira.de.andrade@gmail.com> Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
-rw-r--r--src/Text.c2
1 files changed, 1 insertions, 1 deletions
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;
}