Commit a7fb4b64 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

(free_all_cache): Don't attempt to access Pers_no, Conf_no or Text_no 0.

(get_conf_node): Fail if the argument is less than 1.
(get_pers_node): Likewise.
(get_text_node): Likewise.
(traverse_person): Unused function; don't compile it.
parent 38a7c417
/*
* $Id: simple-cache.c,v 0.67 1998/07/26 16:42:45 ceder Exp $
* $Id: simple-cache.c,v 0.68 1998/08/14 18:54:48 ceder Exp $
* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996 Lysator Academic Computer Association.
*
* This file is part of the LysKOM server.
......@@ -35,7 +35,7 @@
*/
static const char *
rcsid = "$Id: simple-cache.c,v 0.67 1998/07/26 16:42:45 ceder Exp $";
rcsid = "$Id: simple-cache.c,v 0.68 1998/08/14 18:54:48 ceder Exp $";
#include "rcs.h"
USE(rcsid);
......@@ -312,7 +312,7 @@ conf_set_mru(Conf_no conf_no)
static Cache_node *
get_pers_node(Pers_no pers_no)
{
if ( pers_no >= next_free_num )
if (pers_no >= next_free_num || pers_no < 1)
return NULL;
return get_cache_node(pers_mcb, pers_no);
......@@ -339,7 +339,7 @@ unlink_pers_lru (Cache_node *node)
static Cache_node *
get_conf_node(Conf_no conf_no)
{
if ( conf_no >= next_free_num )
if (conf_no >= next_free_num || conf_no < 1)
return NULL;
return get_cache_node(conf_mcb, conf_no);
......@@ -348,7 +348,7 @@ get_conf_node(Conf_no conf_no)
static Cache_node *
get_text_node(Text_no text_no)
{
if ( text_no >= next_text_num )
if (text_no >= next_text_num || text_no < 1)
return NULL;
return get_cache_node(text_mcb, text_no);
......@@ -1065,6 +1065,7 @@ traverse_text(Text_no seed)
return (seed >= next_text_num) ? 0 : seed ;
}
#if 0 /* This is not used, but should work OK. */
Pers_no
traverse_person(Pers_no seed)
{
......@@ -1083,6 +1084,7 @@ traverse_person(Pers_no seed)
return (seed >= next_free_num) ? 0 : seed ;
}
#endif
Conf_no
traverse_conference(Conf_no seed)
......@@ -2445,7 +2447,7 @@ free_all_cache (void)
fclose(logfile);
#endif
for ( i = 0; i < next_free_num; i++ )
for ( i = 1; i < next_free_num; i++ )
{
node = get_conf_node(i);
if ( node != NULL )
......@@ -2490,7 +2492,7 @@ free_all_cache (void)
}
}
for ( i = 0; i < next_text_num; i++ )
for ( i = 1; i < next_text_num; i++ )
{
node = get_text_node(i);
if ( node != NULL )
......
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