summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas E. Dickey <dickey@invisible-island.net>2024-03-01 17:01:07 -0500
committerThomas E. Dickey <dickey@invisible-island.net>2024-03-02 16:25:29 -0500
commitff9312d99940be2d81d91601ad6c1688da1016bd (patch)
tree88d799cf38c453cebb01a9e113192befea3b352b
parentcc1e73a85d437ebd0d5c8efbe14a7f398c1b9fcc (diff)
fix references to uninitialized data when constructing argument-lists
Signed-off-by: Thomas E. Dickey <dickey@invisible-island.net>
-rw-r--r--src/XawIm.c254
1 files changed, 138 insertions, 116 deletions
diff --git a/src/XawIm.c b/src/XawIm.c
index 81d32df..24daa35 100644
--- a/src/XawIm.c
+++ b/src/XawIm.c
@@ -80,6 +80,18 @@ in this Software without prior written authorization from The Open Group.
#define Offset(field) (XtOffsetOf(XawIcTablePart, field))
+#define ADD_IC(value) ic_a[ic_cnt] = (XPointer) value; ic_cnt++
+#define USE_IC(count) (ic_cnt > count) ? ic_a[count] : NULL
+#define END_IC() ic_a[ic_cnt] = (XPointer) NULL
+
+#define ADD_PE(value) pe_a[pe_cnt] = (XPointer) value; pe_cnt++
+#define USE_PE(count) (pe_cnt > count) ? pe_a[count] : NULL
+#define END_PE() pe_a[pe_cnt] = (XPointer) NULL
+
+#define ADD_ST(value) st_a[st_cnt] = (XPointer) value; st_cnt++
+#define USE_ST(count) (st_cnt > count) ? st_a[count] : NULL
+#define END_ST() st_a[st_cnt] = (XPointer) NULL
+
/*****************************************************
*
* Forward reference prototypes
@@ -723,18 +735,18 @@ SizeNegotiation(XawIcTableList p, unsigned int width, unsigned int height)
if (p->input_style & XIMPreeditArea) {
pe_attr = XVaCreateNestedList(0, XNAreaNeeded, &pe_area_needed, NULL);
- ic_a[ic_cnt] = (XPointer) XNPreeditAttributes; ic_cnt++;
- ic_a[ic_cnt] = (XPointer) pe_attr; ic_cnt++;
+ ADD_IC(XNPreeditAttributes);
+ ADD_IC(pe_attr);
}
if (p->input_style & XIMStatusArea) {
st_attr = XVaCreateNestedList(0, XNAreaNeeded, &st_area_needed, NULL);
- ic_a[ic_cnt] = (XPointer) XNStatusAttributes; ic_cnt++;
- ic_a[ic_cnt] = (XPointer) st_attr; ic_cnt++;
+ ADD_IC(XNStatusAttributes);
+ ADD_IC(st_attr);
}
- ic_a[ic_cnt] = (XPointer) NULL;
+ END_IC();
if (ic_cnt > 0) {
- XGetICValues(p->xic, ic_a[0], ic_a[1], ic_a[2], ic_a[3], NULL);
+ XGetICValues(p->xic, USE_IC(0), USE_IC(1), USE_IC(2), USE_IC(3), NULL);
if (pe_attr) XFree(pe_attr);
if (st_attr) XFree(st_attr);
if (p->xic == NULL) {
@@ -755,8 +767,8 @@ SizeNegotiation(XawIcTableList p, unsigned int width, unsigned int height)
XFree(st_area_needed);
st_attr = XVaCreateNestedList(0, XNArea, &st_area, NULL);
- ic_a[ic_cnt] = (XPointer) XNStatusAttributes; ic_cnt++;
- ic_a[ic_cnt] = (XPointer) st_attr; ic_cnt++;
+ ADD_IC(XNStatusAttributes);
+ ADD_IC(st_attr);
}
if (p->input_style & XIMPreeditArea) {
if (p->input_style & XIMStatusArea) {
@@ -770,11 +782,11 @@ SizeNegotiation(XawIcTableList p, unsigned int width, unsigned int height)
XFree(pe_area_needed);
pe_area.y = (short)(height - pe_area.height);
pe_attr = XVaCreateNestedList(0, XNArea, &pe_area, NULL);
- ic_a[ic_cnt] = (XPointer) XNPreeditAttributes; ic_cnt++;
- ic_a[ic_cnt] = (XPointer) pe_attr; ic_cnt++;
+ ADD_IC(XNPreeditAttributes);
+ ADD_IC(pe_attr);
}
- ic_a[ic_cnt] = (XPointer) NULL;
- XSetICValues(p->xic, ic_a[0], ic_a[1], ic_a[2], ic_a[3], NULL);
+ END_IC();
+ XSetICValues(p->xic, USE_IC(0), USE_IC(1), USE_IC(2), USE_IC(3), NULL);
if (pe_attr) XFree(pe_attr);
if (st_attr) XFree(st_attr);
if (p->xic == NULL) {
@@ -806,10 +818,10 @@ CreateIC(Widget w, XawVendorShellExtPart *ve)
if (p->input_style & (XIMPreeditArea|XIMPreeditPosition|XIMStatusArea)) {
if (p->flg & CIFontSet) {
- pe_a[pe_cnt] = (XPointer) XNFontSet; pe_cnt++;
- pe_a[pe_cnt] = (XPointer) p->font_set; pe_cnt++;
- st_a[st_cnt] = (XPointer) XNFontSet; st_cnt++;
- st_a[st_cnt] = (XPointer) p->font_set; st_cnt++;
+ ADD_PE(XNFontSet);
+ ADD_PE(p->font_set);
+ ADD_ST(XNFontSet);
+ ADD_ST(p->font_set);
if (p->font_set) {
height = (Dimension)(maxAscentOfFontSet(p->font_set)
+ maxDescentOfFontSet(p->font_set));
@@ -817,28 +829,28 @@ CreateIC(Widget w, XawVendorShellExtPart *ve)
height = (Dimension)SetVendorShellHeight(ve, height);
}
if (p->flg & CIFg) {
- pe_a[pe_cnt] = (XPointer) XNForeground; pe_cnt++;
- pe_a[pe_cnt] = (XPointer) p->foreground; pe_cnt++;
- st_a[st_cnt] = (XPointer) XNForeground; st_cnt++;
- st_a[st_cnt] = (XPointer) p->foreground; st_cnt++;
+ ADD_PE(XNForeground);
+ ADD_PE(p->foreground);
+ ADD_ST(XNForeground);
+ ADD_ST(p->foreground);
}
if (p->flg & CIBg) {
- pe_a[pe_cnt] = (XPointer) XNBackground; pe_cnt++;
- pe_a[pe_cnt] = (XPointer) p->background; pe_cnt++;
- st_a[st_cnt] = (XPointer) XNBackground; st_cnt++;
- st_a[st_cnt] = (XPointer) p->background; st_cnt++;
+ ADD_PE(XNBackground);
+ ADD_PE(p->background);
+ ADD_ST(XNBackground);
+ ADD_ST(p->background);
}
if (p->flg & CIBgPixmap) {
- pe_a[pe_cnt] = (XPointer) XNBackgroundPixmap; pe_cnt++;
- pe_a[pe_cnt] = (XPointer) p->bg_pixmap; pe_cnt++;
- st_a[st_cnt] = (XPointer) XNBackgroundPixmap; st_cnt++;
- st_a[st_cnt] = (XPointer) p->bg_pixmap; st_cnt++;
+ ADD_PE(XNBackgroundPixmap);
+ ADD_PE(p->bg_pixmap);
+ ADD_ST(XNBackgroundPixmap);
+ ADD_ST(p->bg_pixmap);
}
if (p->flg & CILineS) {
- pe_a[pe_cnt] = (XPointer) XNLineSpace; pe_cnt++;
- pe_a[pe_cnt] = (XPointer) p->line_spacing; pe_cnt++;
- st_a[st_cnt] = (XPointer) XNLineSpace; st_cnt++;
- st_a[st_cnt] = (XPointer) p->line_spacing; st_cnt++;
+ ADD_PE(XNLineSpace);
+ ADD_PE(p->line_spacing);
+ ADD_ST(XNLineSpace);
+ ADD_ST(p->line_spacing);
}
}
@@ -847,8 +859,8 @@ CreateIC(Widget w, XawVendorShellExtPart *ve)
pe_area.y = (short)(ve->parent->core.height - height);
pe_area.width = ve->parent->core.width;
pe_area.height = height;
- pe_a[pe_cnt] = (XPointer) XNArea; pe_cnt++;
- pe_a[pe_cnt] = (XPointer) &pe_area; pe_cnt++;
+ ADD_PE(XNArea);
+ ADD_PE(&pe_area);
}
if (p->input_style & XIMPreeditPosition) {
@@ -863,59 +875,64 @@ CreateIC(Widget w, XawVendorShellExtPart *ve)
pe_area.y = (short)(pe_area.y + margin->top);
pe_area.width = (unsigned short)(pe_area.width - (margin->left + margin->right - 1));
pe_area.height = (unsigned short)(pe_area.height - (margin->top + margin->bottom - 1));
- pe_a[pe_cnt] = (XPointer) XNArea; pe_cnt++;
- pe_a[pe_cnt] = (XPointer) &pe_area; pe_cnt++;
+ ADD_PE(XNArea);
+ ADD_PE(&pe_area);
if (p->flg & CICursorP) {
_XawMultiSinkPosToXY(w, p->cursor_position, &position.x, &position.y);
} else {
position.x = position.y = 0;
}
- pe_a[pe_cnt] = (XPointer) XNSpotLocation; pe_cnt++;
- pe_a[pe_cnt] = (XPointer) &position; pe_cnt++;
+ ADD_PE(XNSpotLocation);
+ ADD_PE(&position);
}
if (p->input_style & XIMStatusArea) {
st_area.x = 0;
st_area.y = (short)(ve->parent->core.height - height);
st_area.width = ve->parent->core.width;
st_area.height = height;
- st_a[st_cnt] = (XPointer) XNArea; st_cnt++;
- st_a[st_cnt] = (XPointer) &st_area; st_cnt++;
+ ADD_ST(XNArea);
+ ADD_ST(&st_area);
}
- ic_a[ic_cnt] = (XPointer) XNInputStyle; ic_cnt++;
- ic_a[ic_cnt] = (XPointer) p->input_style; ic_cnt++;
- ic_a[ic_cnt] = (XPointer) XNClientWindow; ic_cnt++;
- ic_a[ic_cnt] = (XPointer) XtWindow(ve->parent); ic_cnt++;
- ic_a[ic_cnt] = (XPointer) XNFocusWindow; ic_cnt++;
- ic_a[ic_cnt] = (XPointer) XtWindow(w); ic_cnt++;
+ ADD_IC(XNInputStyle);
+ ADD_IC(p->input_style);
+ ADD_IC(XNClientWindow);
+ ADD_IC(XtWindow(ve->parent));
+ ADD_IC(XNFocusWindow);
+ ADD_IC(XtWindow(w));
if (pe_cnt > 0) {
- pe_a[pe_cnt] = (XPointer) NULL;
- pe_attr = XVaCreateNestedList(0, pe_a[0], pe_a[1], pe_a[2], pe_a[3],
- pe_a[4], pe_a[5], pe_a[6], pe_a[7], pe_a[8],
- pe_a[9], pe_a[10], pe_a[11], pe_a[12],
- pe_a[13], pe_a[14], pe_a[15], pe_a[16],
- pe_a[17], pe_a[18], NULL);
- ic_a[ic_cnt] = (XPointer) XNPreeditAttributes; ic_cnt++;
- ic_a[ic_cnt] = (XPointer) pe_attr; ic_cnt++;
+ END_PE();
+ pe_attr = XVaCreateNestedList(0, USE_PE(0), USE_PE(1), USE_PE(2),
+ USE_PE(3), USE_PE(4), USE_PE(5),
+ USE_PE(6), USE_PE(7), USE_PE(8),
+ USE_PE(9), USE_PE(10), USE_PE(11),
+ USE_PE(12), USE_PE(13), USE_PE(14),
+ USE_PE(15), USE_PE(16), USE_PE(17),
+ USE_PE(18), NULL);
+ ADD_IC(XNPreeditAttributes);
+ ADD_IC(pe_attr);
}
if (st_cnt > 0) {
- st_a[st_cnt] = (XPointer) NULL;
- st_attr = XVaCreateNestedList(0, st_a[0], st_a[1], st_a[2], st_a[3],
- st_a[4], st_a[5], st_a[6], st_a[7], st_a[8],
- st_a[9], st_a[10], st_a[11], st_a[12],
- st_a[13], st_a[14], st_a[15], st_a[16],
- st_a[17], st_a[18], NULL);
- ic_a[ic_cnt] = (XPointer) XNStatusAttributes; ic_cnt++;
- ic_a[ic_cnt] = (XPointer) st_attr; ic_cnt++;
- }
- ic_a[ic_cnt] = (XPointer) NULL;
-
- p->xic = XCreateIC(ve->im.xim, ic_a[0], ic_a[1], ic_a[2], ic_a[3],
- ic_a[4], ic_a[5], ic_a[6], ic_a[7], ic_a[8], ic_a[9],
- ic_a[10], ic_a[11], ic_a[12], ic_a[13], ic_a[14],
- ic_a[15], ic_a[16], ic_a[17], ic_a[18], NULL);
+ END_ST();
+ st_attr = XVaCreateNestedList(0, USE_ST(0), USE_ST(1), USE_ST(2),
+ USE_ST(3), USE_ST(4), USE_ST(5),
+ USE_ST(6), USE_ST(7), USE_ST(8),
+ USE_ST(9), USE_ST(10), USE_ST(11),
+ USE_ST(12), USE_ST(13), USE_ST(14),
+ USE_ST(15), USE_ST(16), USE_ST(17),
+ USE_ST(18), NULL);
+ ADD_IC(XNStatusAttributes);
+ ADD_IC(st_attr);
+ }
+ END_IC();
+
+ p->xic = XCreateIC(ve->im.xim, USE_IC(0), USE_IC(1), USE_IC(2), USE_IC(3),
+ USE_IC(4), USE_IC(5), USE_IC(6), USE_IC(7), USE_IC(8),
+ USE_IC(9), USE_IC(10), USE_IC(11), USE_IC(12),
+ USE_IC(13), USE_IC(14), USE_IC(15), USE_IC(16),
+ USE_IC(17), USE_IC(18), NULL);
if (pe_attr) XtFree(pe_attr);
if (st_attr) XtFree(st_attr);
@@ -969,10 +986,10 @@ SetICValues(Widget w, XawVendorShellExtPart *ve, Bool focus)
if (p->input_style & (XIMPreeditArea|XIMPreeditPosition|XIMStatusArea)) {
if (p->flg & CIFontSet) {
- pe_a[pe_cnt] = (XPointer) XNFontSet; pe_cnt++;
- pe_a[pe_cnt] = (XPointer) p->font_set; pe_cnt++;
- st_a[st_cnt] = (XPointer) XNFontSet; st_cnt++;
- st_a[st_cnt] = (XPointer) p->font_set; st_cnt++;
+ ADD_PE(XNFontSet);
+ ADD_PE(p->font_set);
+ ADD_ST(XNFontSet);
+ ADD_ST(p->font_set);
if (p->font_set) {
height = maxAscentOfFontSet(p->font_set)
+ maxDescentOfFontSet(p->font_set);
@@ -980,35 +997,35 @@ SetICValues(Widget w, XawVendorShellExtPart *ve, Bool focus)
height = (int)SetVendorShellHeight(ve, (unsigned)height);
}
if (p->flg & CIFg) {
- pe_a[pe_cnt] = (XPointer) XNForeground; pe_cnt++;
- pe_a[pe_cnt] = (XPointer) p->foreground; pe_cnt++;
- st_a[st_cnt] = (XPointer) XNForeground; st_cnt++;
- st_a[st_cnt] = (XPointer) p->foreground; st_cnt++;
+ ADD_PE(XNForeground);
+ ADD_PE(p->foreground);
+ ADD_ST(XNForeground);
+ ADD_ST(p->foreground);
}
if (p->flg & CIBg) {
- pe_a[pe_cnt] = (XPointer) XNBackground; pe_cnt++;
- pe_a[pe_cnt] = (XPointer) p->background; pe_cnt++;
- st_a[st_cnt] = (XPointer) XNBackground; st_cnt++;
- st_a[st_cnt] = (XPointer) p->background; st_cnt++;
+ ADD_PE(XNBackground);
+ ADD_PE(p->background);
+ ADD_ST(XNBackground);
+ ADD_ST(p->background);
}
if (p->flg & CIBgPixmap) {
- pe_a[pe_cnt] = (XPointer) XNBackgroundPixmap; pe_cnt++;
- pe_a[pe_cnt] = (XPointer) p->bg_pixmap; pe_cnt++;
- st_a[st_cnt] = (XPointer) XNBackgroundPixmap; st_cnt++;
- st_a[st_cnt] = (XPointer) p->bg_pixmap; st_cnt++;
+ ADD_PE(XNBackgroundPixmap);
+ ADD_PE(p->bg_pixmap);
+ ADD_ST(XNBackgroundPixmap);
+ ADD_ST(p->bg_pixmap);
}
if (p->flg & CILineS) {
- pe_a[pe_cnt] = (XPointer) XNLineSpace; pe_cnt++;
- pe_a[pe_cnt] = (XPointer) p->line_spacing; pe_cnt++;
- st_a[st_cnt] = (XPointer) XNLineSpace; st_cnt++;
- st_a[st_cnt] = (XPointer) p->line_spacing; st_cnt++;
+ ADD_PE(XNLineSpace);
+ ADD_PE(p->line_spacing);
+ ADD_ST(XNLineSpace);
+ ADD_ST(p->line_spacing);
}
}
if (p->input_style & XIMPreeditPosition) {
if (p->flg & CICursorP) {
_XawMultiSinkPosToXY(w, p->cursor_position, &position.x, &position.y);
- pe_a[pe_cnt] = (XPointer) XNSpotLocation; pe_cnt++;
- pe_a[pe_cnt] = (XPointer) &position; pe_cnt++;
+ ADD_PE(XNSpotLocation);
+ ADD_PE(&position);
}
}
if (IsSharedIC(ve)) {
@@ -1022,41 +1039,46 @@ SetICValues(Widget w, XawVendorShellExtPart *ve, Bool focus)
pe_area.y = (short)(pe_area.y + margin->top);
pe_area.width = (unsigned short)(pe_area.width - (margin->left + margin->right - 1));
pe_area.height = (unsigned short)(pe_area.height - (margin->top + margin->bottom - 1));
- pe_a[pe_cnt] = (XPointer) XNArea; pe_cnt++;
- pe_a[pe_cnt] = (XPointer) &pe_area; pe_cnt++;
+ ADD_PE(XNArea);
+ ADD_PE(&pe_area);
}
}
if (pe_cnt > 0) {
- pe_a[pe_cnt] = (XPointer) NULL;
- pe_attr = XVaCreateNestedList(0, pe_a[0], pe_a[1], pe_a[2], pe_a[3],
- pe_a[4], pe_a[5], pe_a[6], pe_a[7],
- pe_a[8], pe_a[9], pe_a[10], pe_a[11],
- pe_a[12], pe_a[13], pe_a[14], pe_a[15],
- pe_a[16], pe_a[17], pe_a[18], NULL);
- ic_a[ic_cnt] = (XPointer) XNPreeditAttributes; ic_cnt++;
- ic_a[ic_cnt] = (XPointer) pe_attr; ic_cnt++;
+ END_PE();
+ pe_attr = XVaCreateNestedList(0, USE_PE(0), USE_PE(1), USE_PE(2),
+ USE_PE(3), USE_PE(4), USE_PE(5),
+ USE_PE(6), USE_PE(7), USE_PE(8),
+ USE_PE(9), USE_PE(10), USE_PE(11),
+ USE_PE(12), USE_PE(13), USE_PE(14),
+ USE_PE(15), USE_PE(16), USE_PE(17),
+ USE_PE(18), NULL);
+ ADD_IC(XNPreeditAttributes);
+ ADD_IC(pe_attr);
}
if (st_cnt > 0) {
- st_a[st_cnt] = (XPointer) NULL;
- st_attr = XVaCreateNestedList(0, st_a[0], st_a[1], st_a[2], st_a[3],
- st_a[4], st_a[5], st_a[6], st_a[7],
- st_a[8], st_a[9], st_a[10], st_a[11],
- st_a[12], st_a[13], st_a[14], st_a[15],
- st_a[16], st_a[17], st_a[18], NULL);
- ic_a[ic_cnt] = (XPointer) XNStatusAttributes; ic_cnt++;
- ic_a[ic_cnt] = (XPointer) st_attr; ic_cnt++;
+ END_ST();
+ st_attr = XVaCreateNestedList(0, USE_ST(0), USE_ST(1), USE_ST(2),
+ USE_ST(3), USE_ST(4), USE_ST(5),
+ USE_ST(6), USE_ST(7), USE_ST(8),
+ USE_ST(9), USE_ST(10), USE_ST(11),
+ USE_ST(12), USE_ST(13), USE_ST(14),
+ USE_ST(15), USE_ST(16), USE_ST(17),
+ USE_ST(18), NULL);
+ ADD_IC(XNStatusAttributes);
+ ADD_IC(st_attr);
}
if (focus == TRUE) {
- ic_a[ic_cnt] = (XPointer) XNFocusWindow; ic_cnt++;
- ic_a[ic_cnt] = (XPointer) XtWindow(w); ic_cnt++;
+ ADD_IC(XNFocusWindow);
+ ADD_IC(XtWindow(w));
}
if (ic_cnt > 0) {
- ic_a[ic_cnt] = (XPointer) NULL;
- XSetICValues(p->xic, ic_a[0], ic_a[1], ic_a[2], ic_a[3], ic_a[4],
- ic_a[5], ic_a[6], ic_a[7], ic_a[8], ic_a[9], ic_a[10],
- ic_a[11], ic_a[12], ic_a[13], ic_a[14], ic_a[15],
- ic_a[16], ic_a[17], ic_a[18], NULL);
+ END_IC();
+ XSetICValues(p->xic, USE_IC(0), USE_IC(1), USE_IC(2), USE_IC(3),
+ USE_IC(4), USE_IC(5), USE_IC(6), USE_IC(7), USE_IC(8),
+ USE_IC(9), USE_IC(10), USE_IC(11), USE_IC(12), USE_IC(13),
+ USE_IC(14), USE_IC(15), USE_IC(16), USE_IC(17),
+ USE_IC(18), NULL);
if (pe_attr) XtFree(pe_attr);
if (st_attr) XtFree(st_attr);
}