Branch: Tag:

2006-06-09

2006-06-09 18:21:52 by Martin Stjernholm <mast@lysator.liu.se>

Fixed bug with uninitialized bytes in the node svalues which valgrind
complains about. This could cause bogus hashes, but since the shared node
stuff is defeated anyway the bug probably had no real effect.

Rev: src/las.c:1.351

2:   || This file is part of Pike. For copyright information see COPYRIGHT.   || Pike is distributed under GPL, LGPL and MPL. See the file COPYING   || for more information. - || $Id: las.c,v 1.350 2006/03/02 10:39:47 grubba Exp $ + || $Id: las.c,v 1.351 2006/06/09 18:21:52 mast Exp $   */      #include "global.h" - RCSID("$Id: las.c,v 1.350 2006/03/02 10:39:47 grubba Exp $"); + RCSID("$Id: las.c,v 1.351 2006/06/09 18:21:52 mast Exp $");      #include "language.h"   #include "interpret.h"
2052:   {    node *res = mkemptynode();    res->token = F_CONSTANT; -  assign_svalue_no_free(& res->u.sval, s); +    #ifdef SHARED_NODES -  if (s->type != T_INT && s->type != T_FUNCTION) -  /* The subtype is part of the hash, so make sure it got a defined -  * value here. */ -  res->u.sval.subtype = 0; +  /* We need to ensure that all bytes in the svalue struct have well +  * defined values, including any padding between the subtype and the +  * union. */ +  switch (res->u.sval.type = s->type) { +  case T_INT: +  res->u.sval.u.integer = s->u.integer; +  res->u.sval.subtype = s->subtype; +  break; +  case T_FLOAT: +  res->u.sval.u.float_number = s->u.float_number; +  break; +  case T_FUNCTION: +  res->u.sval.subtype = s->subtype; +  /* FALL THROUGH */ +  default: +  res->u.sval.u.ptr = s->u.ptr; +  } +  add_ref_svalue (&res->u.sval); + #else +  assign_svalue_no_free(& res->u.sval, s);   #endif    if(s->type == T_OBJECT ||    (s->type==T_FUNCTION && s->subtype!=FUNCTION_BUILTIN))