Branch: Tag:

2001-08-13

2001-08-13 23:01:22 by Martin Stjernholm <mast@lysator.liu.se>

Fixed bug causing the wrong decoded value to be returned when there are
recursive calls to decode_value. Made the recursion check codec and thread
safe.

Rev: src/encode.c:1.126

25:   #include "version.h"   #include "bignum.h"    - RCSID("$Id: encode.c,v 1.125 2001/08/13 21:47:57 hubbe Exp $"); + RCSID("$Id: encode.c,v 1.126 2001/08/13 23:01:22 mast Exp $");      /* #define ENCODE_DEBUG */   
1279:    int pickyness;    struct pike_string *raw;    struct decode_data *next; + #ifdef PIKE_THREADS +  struct object *thread_id; + #endif   #ifdef ENCODE_DEBUG    int debug, depth;   #endif
2582:    }   #endif /* PIKE_DEBUG */    } + #ifdef PIKE_THREADS +  free_object(data->thread_id); + #endif   }      static INT32 my_decode(struct pike_string *tmp,
2596:       /* Attempt to avoid infinite recursion on circular structures. */    for (data = current_decode; data; data=data->next) { -  if (data->raw == tmp) { +  if (data->raw == tmp && data->codec == codec + #ifdef PIKE_THREADS +  && data->thread_id == Pike_interpreter.thread_id + #endif +  ) {    struct svalue *res;    struct svalue val = {    T_INT, NUMBER_NUMBER,
2604:    {0}, /* Only to avoid warnings. */   #endif /* HAVE_UNION_INIT */    }; -  val.u.integer = 0; +  val.u.integer = COUNTER_START;    if ((res = low_mapping_lookup(data->decoded, &val))) {    push_svalue(res);    return 1;
2626:    data->unfinished_objects=0;    data->raw = tmp;    data->next = current_decode; + #ifdef PIKE_THREADS +  data->thread_id = Pike_interpreter.thread_id; +  add_ref(Pike_interpreter.thread_id); + #endif   #ifdef ENCODE_DEBUG    data->debug = debug;    data->depth = -2;