From ae69a754244c4e475c8d2591772ca8e005071d83 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 18 Feb 2019 11:55:41 +0100 Subject: Update to 5.42 --- utils/Makefile.in | 2 +- utils/colors.c | 15 ++++++++++++++- utils/erase.c | 2 +- utils/font-retry.c | 43 ++++++++++++++++++++++++++++++------------- utils/textclient-mobile.c | 14 ++++++++++---- utils/version.h | 2 +- utils/yarandom.h | 34 ++++++++++++++++++++++++++++++++-- 7 files changed, 89 insertions(+), 23 deletions(-) (limited to 'utils') diff --git a/utils/Makefile.in b/utils/Makefile.in index 56fc602..dbb593b 100644 --- a/utils/Makefile.in +++ b/utils/Makefile.in @@ -195,7 +195,7 @@ CCUTILS = $(INCLUDES) $(DEFS) $(CPPFLAGS) $(CFLAGS) $(X_CFLAGS) $(CC) -c $(CCUTILS) $< # Two versions of this: driver/ does not link with Xft, but hacks/ does. -font-retry-xft.o: font-retry.c +font-retry-xft.o: $(srcdir)/font-retry.c $(CC) -c $(CCUTILS) -DUSE_XFT $< -o $@ diff --git a/utils/colors.c b/utils/colors.c index e6abd48..5445cd6 100644 --- a/utils/colors.c +++ b/utils/colors.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 1997-2013 Jamie Zawinski +/* xscreensaver, Copyright (c) 1997-2018 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -383,9 +383,22 @@ make_color_path (Screen *screen, Visual *visual, Colormap cmap, /* Floating-point round-off can make us decide to use fewer colors. */ if (k < *ncolorsP) { + /* We used to just return the smaller set of colors, but that meant + that after re-generating the color map repeatedly, the number of + colors in use would tend toward 0, which not only looked bad but + also often caused crashes. So instead, just duplicate the last + color to pad things out. */ +# if 0 *ncolorsP = k; if (k <= 0) return; +# else + for (i = k+1; i < *ncolorsP; i++) + /* #### Should duplicate the allocation of the color cell here + to avoid a double-color-free on PseudoColor, but it's 2018 + and I don't care, */ + colors[i] = colors[k]; +# endif } if (!allocate_p) diff --git a/utils/erase.c b/utils/erase.c index ae15ac8..fdf7496 100644 --- a/utils/erase.c +++ b/utils/erase.c @@ -750,7 +750,7 @@ eraser_init (Display *dpy, Window window) which = -1; else which = get_integer_resource(dpy, "eraseMode", "Integer"); - free (s); + if (s) free (s); if (which < 0 || which >= countof(erasers)) which = random() % countof(erasers); diff --git a/utils/font-retry.c b/utils/font-retry.c index c3e91a0..ab999e2 100644 --- a/utils/font-retry.c +++ b/utils/font-retry.c @@ -25,19 +25,21 @@ extern const char *progname; #undef countof #define countof(x) (sizeof((x))/sizeof((*x))) +#undef DEBUG + static void * load_font_retry_1 (Display *dpy, int screen, const char *xlfd, Bool xft_p) { # ifdef USE_XFT -# define LOADFONT() (xft_p \ - ? (void *) XftFontOpenXlfd (dpy, screen, xlfd) \ - : (void *) XLoadQueryFont (dpy, xlfd)) +# define LOADFONT(F) (xft_p \ + ? (void *) XftFontOpenXlfd (dpy, screen, (F)) \ + : (void *) XLoadQueryFont (dpy, (F))) # else -# define LOADFONT() ((void *) XLoadQueryFont (dpy, xlfd)) +# define LOADFONT(F) ((void *) XLoadQueryFont (dpy, (F))) # endif - void *f = LOADFONT(); + void *f = xlfd ? LOADFONT(xlfd) : 0; # ifndef USE_XFT if (xft_p) abort(); @@ -46,11 +48,18 @@ load_font_retry_1 (Display *dpy, int screen, const char *xlfd, Bool xft_p) # ifdef HAVE_JWXYZ return f; # else /* !HAVE_JWXYZ */ + if (! xlfd) xlfd = ""; if (f) - return f; + { +# ifdef DEBUG + fprintf (stderr, "%s: loaded %s\n", progname, xlfd); +# endif + return f; + } else { - Bool bold_p = (!!strcasestr (xlfd, "-bold-")); + Bool bold_p = (!!strcasestr (xlfd, "-bold-") || + !!strcasestr (xlfd, "-ocr")); Bool italic_p = (!!strcasestr (xlfd, "-i-") || !!strcasestr (xlfd, "-o-")); Bool fixed_p = (!!strcasestr (xlfd, "courier") || @@ -59,6 +68,10 @@ load_font_retry_1 (Display *dpy, int screen, const char *xlfd, Bool xft_p) !!strcasestr (xlfd, "-c-")); int size = 0; +# ifdef DEBUG + fprintf (stderr, "%s: failed %s\n", progname, xlfd); +# endif + if (!strcmp (xlfd, "vga")) /* BSOD uses this: it has no XLFD name. */ fixed_p = True, size = 120; @@ -90,7 +103,7 @@ load_font_retry_1 (Display *dpy, int screen, const char *xlfd, Bool xft_p) fprintf (stderr, "%s: unloadable, unparsable font: \"%s\"\n", progname, xlfd); xlfd = "fixed"; - return LOADFONT(); + return LOADFONT(xlfd); } else { @@ -145,13 +158,17 @@ load_font_retry_1 (Display *dpy, int screen, const char *xlfd, Bool xft_p) spacings[e], "*", /* average width */ charsets[a]); - /* fprintf(stderr, "%s: trying %s\n", progname, buf);*/ - f = LOADFONT(); +# ifdef DEBUG + fprintf(stderr, "%s: trying %s\n", progname, buf); +# endif + f = LOADFONT(buf); if (f) { - /* fprintf (stderr, +# ifdef DEBUG + fprintf (stderr, "%s: substituted \"%s\" for \"%s\"\n", - progname, buf, xlfd); */ + progname, buf, xlfd); +# endif return f; } } @@ -159,7 +176,7 @@ load_font_retry_1 (Display *dpy, int screen, const char *xlfd, Bool xft_p) fprintf (stderr, "%s: unable to find any alternatives to \"%s\"\n", progname, xlfd); xlfd = "fixed"; - return LOADFONT(); + return LOADFONT(xlfd); } } # endif /* !HAVE_JWXYZ */ diff --git a/utils/textclient-mobile.c b/utils/textclient-mobile.c index c321487..4d0d891 100644 --- a/utils/textclient-mobile.c +++ b/utils/textclient-mobile.c @@ -1,4 +1,4 @@ -/* xscreensaver, Copyright (c) 2012-2016 Jamie Zawinski +/* xscreensaver, Copyright (c) 2012-2018 Jamie Zawinski * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -311,11 +311,13 @@ textclient_strip_html (const char *html) int comment = 0; int white = 0; int nl = 0; - char *ret = (char *) malloc ((strlen(html) * 4) + 1); // room for UTF8 + int L = strlen(html); + char *ret = (char *) malloc ((L * 4) + 1); // room for UTF8 char *out = ret; *out = 0; for (const char *in = html; *in; in++) { + if (in >= html + L) abort(); if (comment) { if (!strncmp (in, "-->", 3)) { comment = 0; @@ -339,7 +341,7 @@ textclient_strip_html (const char *html) white = 1; } } else if (*in == ' ' || *in == '\t' || *in == '\r' || *in == '\n') { - if (!white && out != html) + if (!white && out != ret) *out++ = ' '; white = 1; } else { @@ -552,7 +554,8 @@ strip_wiki (char *text) static char * textclient_strip_rss (const char *rss) { - char *ret = malloc (strlen(rss) * 4 + 1); // room for UTF8 + int L = strlen(rss); + char *ret = malloc (L * 4 + 1); // room for UTF8 char *out = ret; const char *a = 0, *b = 0, *c = 0, *d = 0, *t = 0; int head = 1; @@ -561,6 +564,7 @@ textclient_strip_rss (const char *rss) *out = 0; for (const char *in = rss; *in; in++) { + if (in >= rss + L) abort(); if (*in == '<') { if (!strncasecmp (in, " ; } else if (!strncasecmp (in, "= 2) -- cgit v1.2.3-55-g7522