VirtualBox

Changeset 2634 in kBuild for trunk/src


Ignore:
Timestamp:
Sep 8, 2012 11:50:05 PM (12 years ago)
Author:
bird
Message:

kmk/file.c: Fixed double free when CONFIG_WITH_STRCACHE2 is defined. Fixed 2nd expansion bug when CONFIG_WITH_INCLUDEDEP is defined. Fixed GNU make memory leak during 2nd expansion.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk/file.c

    r2591 r2634  
    673673#ifdef CONFIG_WITH_INCLUDEDEP
    674674      /* Dependencies loaded by includedep are ready for use and we skip
    675          the expensive parsing and globbing for them. To avoid wasting
    676          lots of time walking the f->deps chain, we will advance D and
    677          process all subsequent includedep records. */
     675         the expensive parsing and globbing for them.  */
    678676
    679677      if (d->includedep)
    680678        {
    681           struct dep *d1 = new = alloc_dep();
    682           d1->staticpattern = 0;
    683           d1->need_2nd_expansion = 0;
    684           d1->includedep = 1;
    685           d1->file = lookup_file (d->name);
    686           if (d1->file == 0)
    687             d1->file = enter_file (d->name);
    688 
    689           while (d->next && d->next->includedep)
    690             {
    691               d = d->next;
    692               d1 = d1->next = alloc_dep();
    693               d1->staticpattern = 0;
    694               d1->need_2nd_expansion = 0;
    695               d1->includedep = 1;
    696               d1->file = lookup_file (d->name);
    697               if (d1->file == 0)
    698                 d1->file = enter_file (d->name);
    699             }
     679          d->need_2nd_expansion = 0;
     680          d->file = lookup_file (name);
     681          if (d->file == 0)
     682            d->file = enter_file (name);
     683          d->name = 0;
     684          free(name);
     685
     686          dp = &d->next;
     687          d = d->next;
     688          continue;
    700689        }
    701       else
    702       {
    703690#endif /* CONFIG_WITH_INCLUDEDEP */
    704691
     
    711698          o = subst_expand (o, name, "%", "$*", 1, 2, 0);
    712699          *o = '\0';
     700#ifndef CONFIG_WITH_STRCACHE2
    713701          free (name);
    714 #ifndef CONFIG_WITH_STRCACHE2
    715702          d->name = name = xstrdup (variable_buffer); /* bird not d->name, can be reallocated */
    716703#else
     
    758745        }
    759746
    760 #ifdef CONFIG_WITH_INCLUDEDEP
    761       }
    762 #endif
    763 
    764747      /* Add newly parsed prerequisites.  */
    765748      next = d->next;
     749#ifdef KMK /* bird: memory leak */
     750      assert(new != d);
     751      free_dep (d);
     752#endif
    766753      *dp = new;
    767754      for (dp = &new->next, d = new->next; d != 0; dp = &d->next, d = d->next)
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette