# 1.8.0 p3 error

Pavel Curtis (pavel@parc.xerox.com)
Thu, 28 Dec 1995 13:42:07 PST

- Messages sorted by:[ date ][ thread ][ subject ][ author ]

    Kai Storbeck writes:
    > ;for i in (properties(#87));delete_property(#87,i);endfor
    > #-1:Input to EVAL, line 4:  Property not found
    > ... called from built-in function eval()
    > ... called from #57:eval_cmd_string (this == #2), line 18
    > ... called from #57:eval*-d (this == #2), line 10
    > (End of traceback)
    > ;for i in (properties(#87));delete_property(#87,i);endfor
    > *** Shutting down: server panic ***

    This is due to a nasty occasional memory smash in delete_property(); it comes
    up only when you're deleting more than 5/8 of the properties off an object that
    had more than 8 of them.  (I *said* it was occasional...)

    To patch this, replace the entire function db_delete_propdef() in
    db_properties.c with the version given below.

    	Pavel

    PS- This is release 1.8.0alpha3, not 1.8.0p3; that may come later... :-)

    -------------------------------------------------------------------------------
    int
    db_delete_propdef(Objid oid, const char *pname)
    {
        Proplist   *props = &dbpriv_find_object(oid)->propdefs;
        int		hash = str_hash(pname);
        int    	count = props->cur_length;
        int    	max   = props->max_length;
        int		i, j;

        for (i = 0; i < count; i++) {
    	Propdef p;

    	p = props->l[i];
    	if (p.hash == hash  &&  !mystrcasecmp(p.name, pname)) {
    	    if (p.name)
    		free_str(p.name);

    	    if (max > 8  &&  props->cur_length <= ((max * 3) / 8)) {
    		int		new_size = max / 2;
    		Propdef	       *new_props;

    		new_props = mymalloc(new_size * sizeof(Propdef), M_PROPDEF);

    		for (j = 0; j < i; j++)
    		    new_props[j] = props->l[j];
    		for (j = i + 1; j < count; j++)
    		    new_props[j - 1] = props->l[j];

    		myfree(props->l, M_PROPDEF);
    		props->l = new_props;
    		props->max_length = new_size;
    	    } else
    		for (j = i + 1; j < count; j++)
    		    props->l[j - 1] = props->l[j];

    	    props->cur_length--;
    	    remove_prop_recursively(oid, i);

    	    return 1;
    	}
        }

        return 0;
    }
    -------------------------------------------------------------------------------