Branch: Tag:

2021-10-11

2021-10-11 17:25:39 by Henrik Grubbström (Grubba) <grubba@grubba.org>

decode_value: Alloc parent_info_storage for PROGRAM_USES_PARENT.

end_first_pass(0) does not allocate parent_info_storage.
This sometimes caused programs returned by decode_value()
to have both PROGRAM_USES_PARENT and PROGRAM_PASS_1_DONE
set but have a NULL parent_info_storage.
This some code (eg low_clone()) to dereference NULL.

40:   #include <fcntl.h>      static void exit_program_struct(struct program *); - static size_t add_xstorage(size_t size, -  size_t alignment, -  ptrdiff_t modulo_orig); +       /* mapping(int:string) */   static struct mapping *reverse_symbol_table = NULL;
5197:    {    if(Pike_compiler->new_program->flags & PROGRAM_USES_PARENT)    { +  if (!Pike_compiler->new_program->parent_info_storage) {    Pike_compiler->new_program->parent_info_storage =    add_xstorage(sizeof(struct parent_info),    ALIGNOF(struct parent_info),    0); -  +  }    }else{    /* Cause errors if used hopefully */    Pike_compiler->new_program->parent_info_storage=-1;
5364:    * Internal function.    * Adds object storage that will *not* be inherited.    */ - static size_t add_xstorage(size_t size, + size_t add_xstorage(size_t size,    size_t alignment,    ptrdiff_t modulo_orig)   {