Follow-up Comment #3, bug #14415 (project freeciv):

This is the full part of the code:

  if (has_capability("bases", savefile_options)) {
    char **modname = NULL;
    int nmod;
    int j;

    nmod = secfile_lookup_int_default(file, 0, "savefile.num_bases");

    if (nmod > 0) {
      modname = secfile_lookup_str_vec(file, &nmod,
                                       "savefile.bases");
    }

    /* make sure that the size of the array is divisible by 4 */
    base_order = fc_calloc(nmod + (4 - (nmod % 4)), sizeof(*base_order));
    for (j = 0; j < nmod; j++) {
      base_order[j] = find_base_type_by_rule_name(modname[j]);
    }
    free(modname);
    for (; j < game.control.num_base_types + (4 -
(game.control.num_base_types % 4)); j++) {
      base_order[j] = NULL;
    }
  }

As long the memory is allocated with fc_calloc(), base_order[j] = NULL should
be useless.

This base implementations in savegames looks to me very buggy anyway... 
Looking also to:
if (base >= 0
    && base < sizeof(base_order) / sizeof (struct base_type *)) {
at many places of the scores where base_order is of type (struct base_type
**), so sizeof(base_order) is constant pointer size...


    _______________________________________________________

Reply to this item at:

  <http://gna.org/bugs/?14415>

_______________________________________________
  Message posté via/par Gna!
  http://gna.org/


_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to