AnalogTerm2: Additional error checking and fix possible race condition.
authorMatthew Mondor <mmondor@pulsar-zone.net>
Wed, 31 May 2023 07:51:50 +0000 (07:51 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Wed, 31 May 2023 07:51:50 +0000 (07:51 +0000)
mmsoftware/analogterm2/src/main.c
mmsoftware/analogterm2/src/screen.c
mmsoftware/analogterm2/src/tty.c

index b90ef2f..79a9094 100644 (file)
@@ -483,7 +483,7 @@ main(int argc, char **argv, char **envp)
                                        h = atoi(cols[1]);
                                }
                                free(str);
-                               if ((w > 0 && w < 17) && (h > 0 && h < 17)) {
+                               if ((w > 0 && w < 33) && (h > 0 && h < 33)) {
                                        cfg_font_width = w;
                                        cfg_font_height = h;
                                }
index f4f833a..c182386 100644 (file)
@@ -149,16 +149,15 @@ screen_init(void)
        XWindowAttributes wattr;
        int depth, width, height;
 
-       if ((s = malloc(sizeof(screen_t))) == NULL) {
-               /* XXX Good error reporting */
-               goto err;
-       }
+       if ((s = malloc(sizeof(screen_t))) == NULL)
+               err(EXIT_FAILURE, "malloc()");
        screen = s;
-       atexit(screen_cleanup);
 
        s->shm = false;
 
-       s->dpy = XOpenDisplay(NULL);
+       if ((s->dpy = XOpenDisplay(NULL)) == NULL)
+               err(EXIT_FAILURE, "XOpenDisplay()");
+       atexit(screen_cleanup);
 
        if (!XMatchVisualInfo(s->dpy, XDefaultScreen(s->dpy), 24, TrueColor,
            &s->vinfo))
index 0c54f06..c198ae7 100644 (file)
@@ -392,8 +392,6 @@ tty_shell(char **envp, struct winsize *winsize, const char *command)
 {
        tty_t *s;
 
-       sighandler_setup();
-
        if ((s = malloc(sizeof(tty_t))) == NULL)
                err(EXIT_FAILURE, "tty_shell() - malloc()");
        ttys = s;
@@ -403,6 +401,8 @@ tty_shell(char **envp, struct winsize *winsize, const char *command)
        s->winsize = *winsize;
        s->command = command;
 
+       sighandler_setup();
+
        if ((s->shell_pid = child_launch(envp)) == -1)
                err(EXIT_FAILURE, "tty_shell() - child_launch()");