~vcs-imports/pmake/main

Viewing all changes in revision 3516.

  • Committer: rillig
  • Date: 2020-11-29 16:37:10 UTC
  • Revision ID: rillig-20201129163710-bv7txqw0se8d81lp
make(1): fix the reference count of dotLast going negative

The memory management for dotLast is quite simple.  It is initialized
exactly once main_Init > Init_Objdir > Dir_InitDir and freed exactly
once in main_CleanUp > Dir_End.  Previously, dotLast was not freed at all.

The first call to CachedDir_Unref decremented the refCount to 0 but
didn't free anything.  Next, CachedDir_Destroy was called, which
decremented the reference count to -1, therefore skipping the actual
freeing.  This was probably an implementation mistake.

Since Dir_End is called at the very end of main_CleanUp, no code
accesses dotLast after it has been freed.

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: