X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftinfo%2Falloc_entry.c;h=5fd33e76ee8d830f9053001260050bc9ff5aae9f;hp=5de09f1e4b9ff2cdbaacf21b1b43d319ed012907;hb=fe43d506ce08d1deef9e9e5a6d5fd4f9c9c32e1d;hpb=b22573b1ba4b51da883fa5f805b52f153fa5fae9 diff --git a/ncurses/tinfo/alloc_entry.c b/ncurses/tinfo/alloc_entry.c index 5de09f1e..5fd33e76 100644 --- a/ncurses/tinfo/alloc_entry.c +++ b/ncurses/tinfo/alloc_entry.c @@ -1,5 +1,5 @@ /**************************************************************************** - * Copyright (c) 1998-2013,2017 Free Software Foundation, Inc. * + * Copyright (c) 1998-2018,2019 Free Software Foundation, Inc. * * * * Permission is hereby granted, free of charge, to any person obtaining a * * copy of this software and associated documentation files (the * @@ -47,7 +47,7 @@ #include -MODULE_ID("$Id: alloc_entry.c,v 1.60 2017/06/27 23:48:55 tom Exp $") +MODULE_ID("$Id: alloc_entry.c,v 1.63 2019/06/08 14:29:28 tom Exp $") #define ABSENT_OFFSET -1 #define CANCELLED_OFFSET -2 @@ -98,7 +98,7 @@ _nc_save_str(const char *const string) size_t old_next_free = next_free; size_t len; - if (string == 0) + if (!VALID_STRING(string)) return _nc_save_str(""); len = strlen(string) + 1; @@ -227,9 +227,17 @@ _nc_merge_entry(ENTRY * const target, ENTRY * const source) { TERMTYPE2 *to = &(target->tterm); TERMTYPE2 *from = &(source->tterm); +#if NCURSES_XNAMES + TERMTYPE2 copy; +#endif unsigned i; + if (source == 0 || from == 0 || target == 0 || to == 0) + return; + #if NCURSES_XNAMES + _nc_copy_termtype2(©, from); + from = © _nc_align_termtype(to, from); #endif for_each_boolean(i, from) { @@ -269,6 +277,16 @@ _nc_merge_entry(ENTRY * const target, ENTRY * const source) to->Strings[i] = mergestring; } } +#if NCURSES_XNAMES + /* Discard the data allocated in _nc_copy_termtype2, but do not use + * _nc_free_termtype2 because that frees the string-table (which is + * not allocated by _nc_copy_termtype2). + */ + free(copy.Booleans); + free(copy.Numbers); + free(copy.Strings); + free(copy.ext_Names); +#endif } #if NO_LEAKS