]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - ncurses/tty/hashmap.c
ncurses 6.4 - patch 20230625
[ncurses.git] / ncurses / tty / hashmap.c
index 3f124c96c8968e11dad46c37ac8b7d4ea7a44e7f..2ddfaaa29b64f90b3a84f79f0326160e4c0189cf 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright 2019,2020 Thomas E. Dickey                                     *
+ * Copyright 2019-2020,2023 Thomas E. Dickey                                *
  * Copyright 1998-2015,2016 Free Software Foundation, Inc.                  *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
@@ -74,7 +74,7 @@ AUTHOR
 #define CUR SP_TERMTYPE
 #endif
 
-MODULE_ID("$Id: hashmap.c,v 1.69 2020/05/31 17:50:48 tom Exp $")
+MODULE_ID("$Id: hashmap.c,v 1.70 2023/06/25 17:16:01 tom Exp $")
 
 #ifdef HASHDEBUG
 
@@ -318,8 +318,11 @@ NCURSES_SP_NAME(_nc_hash_map) (NCURSES_SP_DCL0)
        if (newhash(SP_PARM) == 0)
            newhash(SP_PARM) = typeCalloc(unsigned long,
                                            (size_t) screen_lines(SP_PARM));
-       if (!oldhash(SP_PARM) || !newhash(SP_PARM))
+       if (!oldhash(SP_PARM) || !newhash(SP_PARM)) {
+           FreeAndNull(oldhash(SP_PARM));
+           FreeAndNull(newhash(SP_PARM));
            return;             /* malloc failure */
+       }
        for (i = 0; i < screen_lines(SP_PARM); i++) {
            newhash(SP_PARM)[i] = hash(SP_PARM, NEWTEXT(SP_PARM, i));
            oldhash(SP_PARM)[i] = hash(SP_PARM, OLDTEXT(SP_PARM, i));