summaryrefslogtreecommitdiff
path: root/oldXMenu
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2021-07-12 00:06:34 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2021-07-12 00:12:21 -0700
commit1a0fe2a5184cd4c57972994cf4b688042aecc534 (patch)
treecb8b1b2c89cd5161d1c12f3aebcb1576f4482b37 /oldXMenu
parent2337869fbf8b967eb53ee57f978f3751987e43dc (diff)
downloademacs-1a0fe2a5184cd4c57972994cf4b688042aecc534.tar.gz
Pacify gcc 11.1.1 -Wanalyzer-possible-null-dereference
* oldXMenu/Create.c (XMenuCreate): * oldXMenu/Internal.c (_XMRecomputePane, _XMRecomputeSelection): * oldXMenu/XMakeAssoc.c (XMakeAssoc): * test/src/emacs-module-resources/mod-test.c (Fmod_test_userptr_make): Don’t assume that malloc and calloc succeed.
Diffstat (limited to 'oldXMenu')
-rw-r--r--oldXMenu/Create.c2
-rw-r--r--oldXMenu/Internal.c31
-rw-r--r--oldXMenu/XMakeAssoc.c2
3 files changed, 16 insertions, 19 deletions
diff --git a/oldXMenu/Create.c b/oldXMenu/Create.c
index 7eb17c508d5..e209bbeceeb 100644
--- a/oldXMenu/Create.c
+++ b/oldXMenu/Create.c
@@ -598,6 +598,8 @@ XMenuCreate(Display *display, Window parent, register char const *def_env)
* Create pane, active, and inactive GC's.
*/
values = (XGCValues *)malloc(sizeof(XGCValues));
+ if (!values)
+ return NULL;
valuemask = (GCForeground | GCBackground | GCFont | GCLineWidth);
/*
diff --git a/oldXMenu/Internal.c b/oldXMenu/Internal.c
index f489e27beab..3e97f9ab3f1 100644
--- a/oldXMenu/Internal.c
+++ b/oldXMenu/Internal.c
@@ -534,7 +534,6 @@ _XMRecomputePane(register Display *display, register XMenu *menu, register XMPan
register int window_y; /* Recomputed window Y coordinate. */
unsigned long change_mask; /* Value mask to reconfigure window. */
- XWindowChanges *changes; /* Values to use in configure window. */
register Bool config_p = False; /* Reconfigure pane window? */
@@ -612,21 +611,19 @@ _XMRecomputePane(register Display *display, register XMenu *menu, register XMPan
* it for creation with the new configuration.
*/
if (p_ptr->window) {
+ XWindowChanges changes;
change_mask = (CWX | CWY | CWWidth | CWHeight);
- changes = (XWindowChanges *)malloc(sizeof(XWindowChanges));
- changes->x = p_ptr->window_x;
- changes->y = p_ptr->window_y;
- changes->width = p_ptr->window_w;
- changes->height = p_ptr->window_h;
+ changes.x = p_ptr->window_x;
+ changes.y = p_ptr->window_y;
+ changes.width = p_ptr->window_w;
+ changes.height = p_ptr->window_h;
XConfigureWindow(
display,
p_ptr->window,
change_mask,
- changes
+ &changes
);
- free(changes);
-
}
else {
if (_XMWinQueAddPane(display, menu, p_ptr) == _FAILURE) {
@@ -681,7 +678,6 @@ _XMRecomputeSelection(register Display *display, register XMenu *menu, register
/* Selection sequence number. */
{
register Bool config_s = False; /* Reconfigure selection window? */
- XWindowChanges *changes; /* Values to change in configure. */
unsigned long change_mask; /* Value mask for XConfigureWindow. */
/*
@@ -738,22 +734,19 @@ _XMRecomputeSelection(register Display *display, register XMenu *menu, register
* for creation with the new configuration.
*/
if (s_ptr->window) {
- changes = (XWindowChanges *)malloc(sizeof(XWindowChanges));
+ XWindowChanges changes;
change_mask = (CWX | CWY | CWWidth | CWHeight);
- changes = (XWindowChanges *)malloc(sizeof(XWindowChanges));
- changes->x = s_ptr->window_x;
- changes->y = s_ptr->window_y;
- changes->width = s_ptr->window_w;
- changes->height = s_ptr->window_h;
+ changes.x = s_ptr->window_x;
+ changes.y = s_ptr->window_y;
+ changes.width = s_ptr->window_w;
+ changes.height = s_ptr->window_h;
XConfigureWindow(
display,
s_ptr->window,
change_mask,
- changes
+ &changes
);
- free(changes);
-
}
else {
if (_XMWinQueAddSelection(display, menu, s_ptr) == _FAILURE) {
diff --git a/oldXMenu/XMakeAssoc.c b/oldXMenu/XMakeAssoc.c
index 9bbde2cf94d..2530e8e507b 100644
--- a/oldXMenu/XMakeAssoc.c
+++ b/oldXMenu/XMakeAssoc.c
@@ -69,6 +69,8 @@ XMakeAssoc(register Display *dpy, register XAssocTable *table, register XID x_id
/* before the current value of "Entry". */
/* Create a new XAssoc and load it with new provided data. */
new_entry = (XAssoc *) malloc(sizeof(XAssoc));
+ if (!new_entry)
+ return; /* This obsolete API has no way to report failure! */
new_entry->display = dpy;
new_entry->x_id = x_id;
new_entry->data = data;