libXmu: Branch 'master' - 4 commits

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Aug 11 21:16:31 UTC 2022


 COPYING            |   22 ++++++++++++++++++++--
 configure.ac       |    8 ++++++++
 src/CloseHook.c    |   14 +++++++-------
 src/CrCmap.c       |   12 ++++++------
 src/CvtCache.c     |    4 ++--
 src/DisplayQue.c   |   12 ++++++------
 src/Distinct.c     |    5 +++--
 src/LocBitmap.c    |    6 +++---
 src/LookupCmap.c   |    6 +++---
 src/Makefile.am    |    3 ++-
 src/RdBitF.c       |    2 +-
 src/Xct.c          |   51 +++++++++++++++++++++++++++------------------------
 src/Xmuint.h       |   42 ++++++++++++++++++++++++++++++++++++++++++
 src/reallocarray.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 14 files changed, 173 insertions(+), 57 deletions(-)

New commits:
commit 0fa4a55d396201974177735cb736a607596130e2
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sat Aug 6 16:15:52 2022 -0700

    Convert code to use Xmumallocarray() & reallocarray()
    
    Provides automatic integer overflow checking in allocation size calculations
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/src/Distinct.c b/src/Distinct.c
index 8c8bb5f..2260769 100644
--- a/src/Distinct.c
+++ b/src/Distinct.c
@@ -35,6 +35,7 @@ in this Software without prior written authorization from The Open Group.
 #include <stdlib.h>
 #include <X11/Xutil.h>
 #include <X11/Xmu/StdCmap.h>
+#include "Xmuint.h"
 
 /*
  * Distinguishable colors routine.  Determines if two colors are
@@ -77,7 +78,7 @@ XmuDistinguishablePixels(Display *dpy, Colormap cmap,
 	for (j = i + 1; j < count; j++)
 	    if (pixels[i] == pixels[j])
 		return False;
-    defs = malloc (count * sizeof (XColor));
+    defs = Xmumallocarray (count, sizeof (XColor));
     if (!defs)
 	return False;
     for (i = 0; i < count; i++)
diff --git a/src/LookupCmap.c b/src/LookupCmap.c
index 31b339a..a78d224 100644
--- a/src/LookupCmap.c
+++ b/src/LookupCmap.c
@@ -37,6 +37,7 @@ in this Software without prior written authorization from The Open Group.
 #include <X11/Xutil.h>
 #include <X11/Xmu/StdCmap.h>
 #include <stdlib.h>
+#include "Xmuint.h"
 
 /*
  * Prototypes
@@ -242,7 +243,7 @@ lookup(Display *dpy, int screen, VisualID visualid, Atom property,
 	if (cnew) {
 	    XStandardColormap	*m, *maps;
 
-	    s = malloc((unsigned) ((count+1) * sizeof(XStandardColormap)));
+	    s = Xmumallocarray((count+1), sizeof(XStandardColormap));
 
 	    for (i = 0, m = s, maps = stdcmaps; i < count; i++, m++, maps++) {
 		m->colormap   = maps->colormap;
diff --git a/src/Xct.c b/src/Xct.c
index 4ca64c5..bfa606e 100644
--- a/src/Xct.c
+++ b/src/Xct.c
@@ -30,6 +30,7 @@ in this Software without prior written authorization from The Open Group.
 #include <X11/Xfuncs.h>
 #include "Xct.h"
 #include <stdio.h>
+#include "Xmuint.h"
 
 #define UsedGraphic	0x0001
 #define UsedDirection	0x0002
@@ -298,6 +299,7 @@ HandleExtended(register XctData data, int c)
 	;
     if (i == priv->enc_count) {
 	XctString cp;
+	char **new_encodings;
 
 	for (cp = enc; cp != ptr; cp++) {
 	    if ((!IsGL(*cp) && !IsGR(*cp)) || (*cp == 0x2a) || (*cp == 0x3f))
@@ -307,11 +309,14 @@ HandleExtended(register XctData data, int c)
 	(void) memmove((char *)ptr, (char *)enc, len);
 	ptr[len] = 0x00;
 	priv->enc_count++;
-	if (priv->encodings)
-	    priv->encodings = realloc(priv->encodings,
-                                      priv->enc_count * sizeof(char *));
-	else
-	    priv->encodings = malloc(sizeof(char *));
+	new_encodings = reallocarray(priv->encodings,
+				     priv->enc_count, sizeof(char *));
+	if (new_encodings == NULL) {
+	    priv->enc_count--;
+	    free(ptr);
+	    return 0;
+	}
+	priv->encodings = new_encodings;
 	priv->encodings[i] = (char *)ptr;
     }
     data->encoding = priv->encodings[i];
@@ -498,14 +503,16 @@ XctNextItem(register XctData data)
 		    ((data->item[1] == 0x31) || (data->item[1] == 0x32))) {
 		    data->horz_depth++;
 		    if (priv->dirsize < data->horz_depth) {
+			XctHDirection *new_dirstack;
 			priv->dirsize += 10;
-			if (priv->dirstack)
-			    priv->dirstack = realloc(priv->dirstack,
-						     priv->dirsize *
-						     sizeof(XctHDirection));
-			else
-			    priv->dirstack = malloc(priv->dirsize *
+			new_dirstack = reallocarray(priv->dirstack,
+						    priv->dirsize,
 						    sizeof(XctHDirection));
+			if (new_dirstack == NULL) {
+			    priv->dirsize -= 10;
+			    return XctError;
+			}
+			priv->dirstack = new_dirstack;
 		    }
 		    priv->dirstack[data->horz_depth - 1] = data->horizontal;
 		    if (data->item[1] == 0x31)
commit 621f61f7d3f5955a84e6aa8b7458699870fdee45
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sat Aug 6 15:38:58 2022 -0700

    Import reallocarray() from libX11 (originally from OpenBSD)
    
    Wrapper for realloc() that checks for overflow when multiplying
    arguments together, so we don't have to add overflow checks to
    every single call.  For documentation on usage, see:
    http://www.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man3/calloc.3
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/COPYING b/COPYING
index b0fbd3e..2ca55c2 100644
--- a/COPYING
+++ b/COPYING
@@ -73,3 +73,21 @@ Except as contained in this notice, the name of the XFree86 Project shall
 not be used in advertising or otherwise to promote the sale, use or other
 dealings in this Software without prior written authorization from the
 XFree86 Project.
+
+-----------
+
+src/reallocarray.c has:
+
+Copyright (c) 2008 Otto Moerbeek <otto at drijf.net>
+
+Permission to use, copy, modify, and distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/configure.ac b/configure.ac
index 50ac183..68f685f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,6 +6,11 @@ AC_INIT([libXmu], [1.1.3],
 AC_CONFIG_SRCDIR([Makefile.am])
 AC_CONFIG_HEADERS([config.h])
 
+# Set common system defines for POSIX extensions, such as _GNU_SOURCE
+# Must be called before any macros that run the compiler (like AC_PROG_LIBTOOL)
+# to avoid autoconf errors.
+AC_USE_SYSTEM_EXTENSIONS
+
 # Initialize Automake
 AM_INIT_AUTOMAKE([foreign dist-xz])
 
@@ -31,6 +36,9 @@ PKG_CHECK_MODULES(XMUU, x11)
 # conversion routines for
 XTRANS_CONNECTION_FLAGS
 
+# Checks for library functions.
+AC_REPLACE_FUNCS([reallocarray])
+
 # Allow checking code with lint, sparse, etc.
 XORG_WITH_LINT
 XORG_LINT_LIBRARY([Xmu])
diff --git a/src/Makefile.am b/src/Makefile.am
index 3aa88d1..a08a8bb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,7 +12,7 @@ AM_CFLAGS = $(CWARNFLAGS) $(XMU_CFLAGS)
 libXmu_la_LDFLAGS = -version-number 6:2:0 -no-undefined
 libXmuu_la_LDFLAGS = -version-number 1:0:0 -no-undefined
 
-libXmu_la_LIBADD = $(XMU_LIBS)
+libXmu_la_LIBADD = $(LTLIBOBJS) $(XMU_LIBS)
 libXmuu_la_LIBADD = $(XMUU_LIBS)
 
 libXmuu_la_SOURCES = \
@@ -24,6 +24,7 @@ libXmuu_la_SOURCES = \
 
 libXmu_la_SOURCES = \
 	$(libXmuu_la_SOURCES) \
+	Xmuint.h \
 	AllCmap.c \
 	Atoms.c \
 	Clip.c \
diff --git a/src/Xmuint.h b/src/Xmuint.h
new file mode 100644
index 0000000..85bc235
--- /dev/null
+++ b/src/Xmuint.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2022, Oracle and/or its affiliates.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef XMUINT_H
+#define XMUINT_H
+
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <X11/Xfuncproto.h>
+#include <sys/types.h>
+
+#ifndef HAVE_REALLOCARRAY
+extern _X_HIDDEN void *Xmureallocarray(void *optr, size_t nmemb, size_t size);
+# define reallocarray(ptr, n, size) Xmureallocarray((ptr), (n), (size))
+#endif
+
+#define Xmumallocarray(n, size) reallocarray(NULL, (n), (size))
+
+#endif /* XMUINT_H */
diff --git a/src/reallocarray.c b/src/reallocarray.c
new file mode 100644
index 0000000..ade402c
--- /dev/null
+++ b/src/reallocarray.c
@@ -0,0 +1,43 @@
+/*	$OpenBSD: reallocarray.c,v 1.2 2014/12/08 03:45:00 bcook Exp $	*/
+/*
+ * Copyright (c) 2008 Otto Moerbeek <otto at drijf.net>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <errno.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include "Xmuint.h"
+
+/*
+ * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX
+ * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW
+ */
+#define MUL_NO_OVERFLOW	((size_t)1 << (sizeof(size_t) * 4))
+
+void *
+Xmureallocarray(void *optr, size_t nmemb, size_t size)
+{
+	if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) &&
+	    nmemb > 0 && SIZE_MAX / nmemb < size) {
+		errno = ENOMEM;
+		return NULL;
+	}
+	return realloc(optr, size * nmemb);
+}
commit 05ee465685aba409800523c6615392a867366818
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sat Aug 6 15:17:27 2022 -0700

    Remove unnnecessary casts from *alloc() and free() calls
    
    These are not needed in C89 and later.
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/src/CloseHook.c b/src/CloseHook.c
index 3eb06ac..d45fc12 100644
--- a/src/CloseHook.c
+++ b/src/CloseHook.c
@@ -117,15 +117,15 @@ XmuAddCloseDisplayHook(Display *dpy, XmuCloseHookProc func, XPointer arg)
     CallbackRec *cb;
 
     /* allocate ahead of time so that we can fail atomically */
-    cb = (CallbackRec *) malloc (sizeof (CallbackRec));
+    cb = malloc (sizeof (CallbackRec));
     if (!cb) return ((XPointer) NULL);
 
     de = _FindDisplayEntry (dpy, NULL);
     if (!de) {
-	if ((de = (DisplayEntry *) malloc (sizeof (DisplayEntry))) == NULL ||
+	if ((de = malloc (sizeof (DisplayEntry))) == NULL ||
 	    !_MakeExtension (dpy, &de->extension)) {
-	    free ((char *) cb);
-	    if (de) free ((char *) de);
+	    free (cb);
+	    free (de);
 	    return ((CloseHook) NULL);
 	}
 	de->dpy = dpy;
@@ -182,7 +182,7 @@ XmuRemoveCloseDisplayHook(Display *dpy, CloseHook handle,
 	prev->next = h->next;
     }
     if (de->end == h) de->end = prev;
-    if (de->calling != h) free ((char *) h);
+    if (de->calling != h) free (h);
     return True;
 }
 
@@ -261,7 +261,7 @@ _DoCallbacks(Display *dpy, XExtCodes *codes)
 	de->calling = h;		/* let remove know we'll free it */
 	(*(h->func)) (dpy, h->arg);
 	de->calling = NULL;
-	free ((char *) h);
+	free (h);
 	h = nexth;
     }
 
@@ -271,7 +271,7 @@ _DoCallbacks(Display *dpy, XExtCodes *codes)
     } else {
 	prev->next = de->next;
     }
-    free ((char *) de);
+    free (de);
     return 1;
 }
 
diff --git a/src/CrCmap.c b/src/CrCmap.c
index b92601d..154aed9 100644
--- a/src/CrCmap.c
+++ b/src/CrCmap.c
@@ -218,13 +218,13 @@ readwrite_map(Display *dpy, XVisualInfo *vinfo, XStandardColormap *colormap)
      * cell, so that is why we do these slow gymnastics.
      */
 
-    if ((pixels = (unsigned long *) calloc((unsigned) vinfo->colormap_size,
-				      sizeof(unsigned long))) == NULL)
+    if ((pixels = calloc((unsigned) vinfo->colormap_size,
+                         sizeof(unsigned long))) == NULL)
 	return 0;
 
     if ((npixels = ROmap(dpy, colormap->colormap, pixels,
 			   vinfo->colormap_size, ncolors)) == 0) {
-	free((char *) pixels);
+	free(pixels);
 	return 0;
     }
 
@@ -235,7 +235,7 @@ readwrite_map(Display *dpy, XVisualInfo *vinfo, XStandardColormap *colormap)
 	/* can't find enough contiguous cells, give up */
 	XFreeColors(dpy, colormap->colormap, pixels, npixels,
 		    (unsigned long) 0);
-	free((char *) pixels);
+	free(pixels);
 	return 0;
     }
     colormap->base_pixel = pixels[first_index];
@@ -326,7 +326,7 @@ readwrite_map(Display *dpy, XVisualInfo *vinfo, XStandardColormap *colormap)
 		    &(pixels[first_index + ncolors]), remainder,
 		    (unsigned long) 0);
 
-    free((char *) pixels);
+    free(pixels);
     return 1;
 }
 
@@ -462,7 +462,7 @@ free_cells(Display *dpy, Colormap cmap, unsigned long pixels[],
      */
     XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0);
     XFreeColors(dpy, cmap, &(pixels[p+1]), npixels - p - 1, (unsigned long) 0);
-    free((char *) pixels);
+    free(pixels);
 }
 
 
diff --git a/src/CvtCache.c b/src/CvtCache.c
index 921b51a..0b1941f 100644
--- a/src/CvtCache.c
+++ b/src/CvtCache.c
@@ -106,7 +106,7 @@ _XmuCCLookupDisplay(Display *dpy)
      */
     e = XmuDQLookupDisplay (dq, dpy);	/* see if it's there */
     if (!e) {				/* else create it */
-	XmuCvtCache *c = (XmuCvtCache *) malloc (sizeof (XmuCvtCache));
+	XmuCvtCache *c = malloc (sizeof (XmuCvtCache));
 	if (!c) return NULL;
 
 	/*
@@ -114,7 +114,7 @@ _XmuCCLookupDisplay(Display *dpy)
 	 */
 	e = XmuDQAddDisplay (dq, dpy, (XPointer) c);
 	if (!e) {
-	    free ((char *) c);
+	    free (c);
 	    return NULL;
 	}
 
diff --git a/src/DisplayQue.c b/src/DisplayQue.c
index 7eea9f2..197689e 100644
--- a/src/DisplayQue.c
+++ b/src/DisplayQue.c
@@ -52,7 +52,7 @@ XmuDQCreate(XmuCloseDisplayQueueProc closefunc,
 	    XmuFreeDisplayQueueProc freefunc,
 	    XPointer data)
 {
-    XmuDisplayQueue *q = (XmuDisplayQueue *) malloc (sizeof (XmuDisplayQueue));
+    XmuDisplayQueue *q = malloc (sizeof (XmuDisplayQueue));
     if (q) {
 	q->nentries = 0;
 	q->head = q->tail = NULL;
@@ -77,10 +77,10 @@ XmuDQDestroy(XmuDisplayQueue *q, Bool docallbacks)
     while (e) {
 	XmuDisplayQueueEntry *nexte = e->next;
 	if (docallbacks && q->closefunc) CallCloseCallback (q, e);
-	free ((char *) e);
+	free (e);
 	e = nexte;
     }
-    free ((char *) q);
+    free (q);
     return True;
 }
 
@@ -109,12 +109,12 @@ XmuDQAddDisplay(XmuDisplayQueue *q, Display *dpy, XPointer data)
 {
     XmuDisplayQueueEntry *e;
 
-    if (!(e = (XmuDisplayQueueEntry *) malloc (sizeof (XmuDisplayQueueEntry)))) {
+    if (!(e = malloc (sizeof (XmuDisplayQueueEntry)))) {
 	return NULL;
     }
     if (!(e->closehook = XmuAddCloseDisplayHook (dpy, _DQCloseDisplay,
 						 (XPointer) q))) {
-	free ((char *) e);
+	free (e);
 	return NULL;
     }
 
@@ -155,7 +155,7 @@ XmuDQRemoveDisplay(XmuDisplayQueue *q, Display *dpy)
 	      e->next->prev = e->prev;	/* else splice out */
 	    (void) XmuRemoveCloseDisplayHook (dpy, e->closehook,
 					      _DQCloseDisplay, (XPointer) q);
-	    free ((char *) e);
+	    free (e);
 	    q->nentries--;
 	    return True;
 	}
diff --git a/src/Distinct.c b/src/Distinct.c
index 9d31494..8c8bb5f 100644
--- a/src/Distinct.c
+++ b/src/Distinct.c
@@ -77,13 +77,13 @@ XmuDistinguishablePixels(Display *dpy, Colormap cmap,
 	for (j = i + 1; j < count; j++)
 	    if (pixels[i] == pixels[j])
 		return False;
-    defs = (XColor *) malloc (count * sizeof (XColor));
+    defs = malloc (count * sizeof (XColor));
     if (!defs)
 	return False;
     for (i = 0; i < count; i++)
 	defs[i].pixel = pixels[i];
     XQueryColors (dpy, cmap, defs, count);
     ret = XmuDistinguishableColors (defs, count);
-    free ((char *) defs);
+    free (defs);
     return ret;
 }
diff --git a/src/LocBitmap.c b/src/LocBitmap.c
index 229d0fd..0c3bc84 100644
--- a/src/LocBitmap.c
+++ b/src/LocBitmap.c
@@ -221,9 +221,9 @@ split_path_string(register char *src)
     for (dst = src; *dst; dst++) if (*dst == ':') nelems++;
 
     /* get memory for everything */
-    dst = (char *) malloc (dst - src + 1);
+    dst = malloc (dst - src + 1);
     if (!dst) return NULL;
-    elemlist = (char **) calloc ((nelems + 1), sizeof (char *));
+    elemlist = calloc ((nelems + 1), sizeof (char *));
     if (!elemlist) {
 	free (dst);
 	return NULL;
@@ -256,6 +256,6 @@ _XmuStringToBitmapFreeCache(register XmuCvtCache *c)
     if (c->string_to_bitmap.bitmapFilePath) {
 	if (c->string_to_bitmap.bitmapFilePath[0])
 	  free (c->string_to_bitmap.bitmapFilePath[0]);
-	free ((char *) (c->string_to_bitmap.bitmapFilePath));
+	free (c->string_to_bitmap.bitmapFilePath);
     }
 }
diff --git a/src/LookupCmap.c b/src/LookupCmap.c
index 4a52290..31b339a 100644
--- a/src/LookupCmap.c
+++ b/src/LookupCmap.c
@@ -242,8 +242,7 @@ lookup(Display *dpy, int screen, VisualID visualid, Atom property,
 	if (cnew) {
 	    XStandardColormap	*m, *maps;
 
-	    s = (XStandardColormap *) malloc((unsigned) ((count+1) * sizeof
-					      (XStandardColormap)));
+	    s = malloc((unsigned) ((count+1) * sizeof(XStandardColormap)));
 
 	    for (i = 0, m = s, maps = stdcmaps; i < count; i++, m++, maps++) {
 		m->colormap   = maps->colormap;
@@ -269,7 +268,7 @@ lookup(Display *dpy, int screen, VisualID visualid, Atom property,
 	    m->killid     = cnew->killid;
 
 	    XSetRGBColormaps(dpy, win, s, ++count, property);
-	    free((char *) s);
+	    free(s);
 	}
 	XFree((char *) stdcmaps);
 	return 0;
diff --git a/src/RdBitF.c b/src/RdBitF.c
index dbea542..51f6e2a 100644
--- a/src/RdBitF.c
+++ b/src/RdBitF.c
@@ -226,7 +226,7 @@ XmuReadBitmapData(FILE *fstream, unsigned int *width, unsigned int *height,
 	bytes_per_line = (ww+7)/8 + padding;
 
 	size = bytes_per_line * hh;
-	data = (unsigned char *) Xmalloc ((unsigned int) size);
+	data = Xmalloc ((unsigned int) size);
 	if (!data)
 	  RETURN (BitmapNoMemory);
 
diff --git a/src/Xct.c b/src/Xct.c
index 9ff8d3c..4ca64c5 100644
--- a/src/Xct.c
+++ b/src/Xct.c
@@ -303,16 +303,15 @@ HandleExtended(register XctData data, int c)
 	    if ((!IsGL(*cp) && !IsGR(*cp)) || (*cp == 0x2a) || (*cp == 0x3f))
 		return 0;
 	}
-	ptr = (XctString)malloc((unsigned)len + 1);
+	ptr = malloc(len + 1);
 	(void) memmove((char *)ptr, (char *)enc, len);
 	ptr[len] = 0x00;
 	priv->enc_count++;
 	if (priv->encodings)
-	    priv->encodings = (char **)realloc(
-					    (char *)priv->encodings,
-					    priv->enc_count * sizeof(char *));
+	    priv->encodings = realloc(priv->encodings,
+                                      priv->enc_count * sizeof(char *));
 	else
-	    priv->encodings = (char **)malloc(sizeof(char *));
+	    priv->encodings = malloc(sizeof(char *));
 	priv->encodings[i] = (char *)ptr;
     }
     data->encoding = priv->encodings[i];
@@ -329,10 +328,9 @@ ShiftGRToGL(register XctData data, int hasCdata)
     if (data->item_length > priv->buf_count) {
 	priv->buf_count = data->item_length;
 	if (priv->itembuf)
-	    priv->itembuf = (XctString)realloc((char *)priv->itembuf,
-					       priv->buf_count);
+	    priv->itembuf = realloc(priv->itembuf, priv->buf_count);
 	else
-	    priv->itembuf = (XctString)malloc(priv->buf_count);
+	    priv->itembuf = malloc(priv->buf_count);
     }
     (void) memmove((char *)priv->itembuf, (char *)data->item,
 		   data->item_length);
@@ -355,7 +353,7 @@ XctCreate(_Xconst unsigned char *string, int length, XctFlags flags)
     register XctData data;
     register XctPriv priv;
 
-    data = (XctData)malloc(sizeof(struct _XctRec) + sizeof(struct _XctPriv));
+    data = malloc(sizeof(struct _XctRec) + sizeof(struct _XctPriv));
     if (!data)
 	return data;
     data->priv = priv = (XctPriv)(data + 1);
@@ -502,13 +500,11 @@ XctNextItem(register XctData data)
 		    if (priv->dirsize < data->horz_depth) {
 			priv->dirsize += 10;
 			if (priv->dirstack)
-			    priv->dirstack = (XctHDirection *)
-					     realloc((char *)priv->dirstack,
+			    priv->dirstack = realloc(priv->dirstack,
 						     priv->dirsize *
 						     sizeof(XctHDirection));
 			else
-			    priv->dirstack = (XctHDirection *)
-					     malloc(priv->dirsize *
+			    priv->dirstack = malloc(priv->dirsize *
 						    sizeof(XctHDirection));
 		    }
 		    priv->dirstack[data->horz_depth - 1] = data->horizontal;
@@ -671,14 +667,14 @@ XctFree(register XctData data)
     register XctPriv priv = data->priv;
 
     if (priv->dirstack)
-	free((char *)priv->dirstack);
+	free(priv->dirstack);
     if (data->flags & XctFreeString)
-	free((char *)data->total_string);
+	free(data->total_string);
     for (i = 0; i < priv->enc_count; i++)
 	free(priv->encodings[i]);
     if (priv->encodings)
-	free((char *)priv->encodings);
+	free(priv->encodings);
     if (priv->itembuf)
-	free((char *)priv->itembuf);
-    free((char *)data);
+	free(priv->itembuf);
+    free(data);
 }
commit f84dcc7fef5e0842e6408f059c13d73975114ec4
Author: Alan Coopersmith <alan.coopersmith at oracle.com>
Date:   Sat Aug 6 16:20:28 2022 -0700

    COPYING: correct source file path names
    
    Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>

diff --git a/COPYING b/COPYING
index d410457..b0fbd3e 100644
--- a/COPYING
+++ b/COPYING
@@ -22,7 +22,7 @@ in this Software without prior written authorization from The Open Group.
 
 -----------
 
-Xmu/StrToBmap.c and Xmu/GrayPixmap.c also have:
+src/StrToBmap.c and src/GrayPixmap.c also have:
 
 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
 
@@ -46,7 +46,7 @@ SOFTWARE.
 
 -----------
 
-Xmu/Clip.c and Xmu/Lookup.h have:
+src/Clip.c and include/X11/Xmu/Lookup.h have:
 
 Copyright (c) 1998 by The XFree86 Project, Inc.
 Copyright 1999 by Thomas E. Dickey <dickey at clark.net>


More information about the xorg-commit mailing list