Commit da97e5a1 authored by Per Cederqvist's avatar Per Cederqvist

(cached_lookup_name): Leaving uninitialized data in the result is

	almost as bad as following the NULL pointer.  The result may
	contain fewer than no_of_match_info entries -- and now the
	code attempts to handle it properly.
parent ea2a7a0d
/*
* $Id: simple-cache.c,v 0.88 1999/07/23 13:02:02 ceder Exp $
* $Id: simple-cache.c,v 0.89 1999/07/24 23:39:53 ceder Exp $
* Copyright (C) 1991-1999 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -40,7 +40,7 @@
#endif
static const char *
rcsid = "$Id: simple-cache.c,v 0.88 1999/07/23 13:02:02 ceder Exp $";
rcsid = "$Id: simple-cache.c,v 0.89 1999/07/24 23:39:53 ceder Exp $";
#include "rcs.h"
USE(rcsid);
......@@ -1514,6 +1514,9 @@ cached_lookup_name(const String name,
Parse_info tmp;
int i;
/* FIXME: It is a waste of resources to include persons here
if this lookup is performed due to a lookup-z-name that
only requests conferences, and vice versa. */
tmp = parse(name, match_table, FALSE, FALSE,
s_fcrea_str(WHITESPACE), DEFAULT_COLLAT_TAB);
......@@ -1527,7 +1530,9 @@ cached_lookup_name(const String name,
if ( tmp.no_of_matches == 1 && tmp.indexes[ 0 ] == -1 )
{
/* Return the entire list. */
result->no_of_conf_nos = no_of_match_info;
/* FIXME: This allocates too much data if some conferences
have been deleted. */
result->no_of_conf_nos = 0;
result->conf_nos = tmp_alloc(no_of_match_info * sizeof(Conf_no));
result->type_of_conf = tmp_alloc(no_of_match_info * sizeof(Conf_type));
......@@ -1535,8 +1540,10 @@ cached_lookup_name(const String name,
{
if (s_empty(match_table[i].name))
continue;
result->conf_nos[ i ] = match_table[i].conf_no;
result->type_of_conf[ i ] = small_conf_arr[ match_table[i].conf_no ]->type;
result->conf_nos[result->no_of_conf_nos] = match_table[i].conf_no;
result->type_of_conf[result->no_of_conf_nos] =
small_conf_arr[match_table[i].conf_no]->type;
result->no_of_conf_nos++;
}
}
else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment