Branch: Tag:

2003-11-18

2003-11-18 14:22:52 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Backported instrs checksum stuff from Pike 7.5.

Rev: src/encode.c:1.164
Rev: src/lex.c:1.113
Rev: src/lex.h:1.27
Rev: src/version.h:1.366

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: encode.c,v 1.163 2003/08/05 14:32:45 grubba Exp $ + || $Id: encode.c,v 1.164 2003/11/18 14:22:52 grubba Exp $   */      #include "global.h"
29:   #include "bignum.h"   #include "pikecode.h"    - RCSID("$Id: encode.c,v 1.163 2003/08/05 14:32:45 grubba Exp $"); + RCSID("$Id: encode.c,v 1.164 2003/11/18 14:22:52 grubba Exp $");      /* #define ENCODE_DEBUG */   
1101:    */    code_number(PIKE_BYTECODE_METHOD, data);    + #ifdef PIKE_USE_MACHINE_CODE +  /* Add the checksum of the instrs array. */ +  code_number(instrs_checksum, data); + #endif /* PIKE_USE_MACHINE_CODE */ +     /* program */   #ifdef ENCODE_PROGRAM   #ifdef PIKE_DEBUG
3125:    Pike_error("Unsupported byte-code method: %d\n", bytecode_method);    }    + #ifdef PIKE_USE_MACHINE_CODE +  { +  size_t csum; +  /* Check the checksum of the instrs array. */ +  decode_number(csum, data); +  if (csum != instrs_checksum) { +  Pike_error("Bad instruction checksum: %d (expected %d)\n", +  csum, instrs_checksum); +  } +  } + #endif /* PIKE_USE_MACHINE_CODE */ +     /* Decode program */    if (data->ptr + (int)local_num_program >= data->len) {    Pike_error("Failed to decode program. (string too short)\n");