diff options
Diffstat (limited to 'src/help.c')
| -rw-r--r-- | src/help.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -225,7 +225,7 @@ teco_help_find(const gchar *topic_name) * Alternatively, we'd have to keep lists in each teco_help_topic_t. */ static gint -teco_help_casecmp(const teco_help_topic_t *topic, const teco_help_topic_t *data) +teco_help_topic_casecmp(const teco_help_topic_t *topic, const teco_help_topic_t *data) { return teco_string_casecmp(topic->head.key, data->head.key.data, data->head.key.len) ? : strcasecmp(topic->filename, data->filename) @@ -240,7 +240,13 @@ static inline void teco_help_set(const gchar *topic_name, const gchar *filename, gsize pos) { teco_help_topic_t *topic = teco_help_topic_new(topic_name, filename, pos); - rb3_insert(&teco_help.tree, &topic->head.head, (rb3_cmp *)teco_help_casecmp, topic); + if (G_UNLIKELY(rb3_insert(&teco_help.tree, &topic->head.head, + (rb3_cmp *)teco_help_topic_casecmp, topic) != NULL)) + /* + * Should not happen - just keep the old entry. + * This will "leak" some memory in the teco_help.chunk, though. + */ + teco_help_topic_free(topic); } gboolean |
