--- src/usr.bin/make/arch.c 2005/01/31 08:30:51 1.27 +++ src/usr.bin/make/arch.c 2005/01/31 21:13:07 1.28 @@ -271,21 +271,20 @@ Arch_ParseArchive(char **linePtr, Lst *n size_t sz; Buffer *buf1; - buf1 = Var_Subst(NULL, memName, ctxt, TRUE); - memName = Buf_GetAll(buf1, NULL); - Buf_Destroy(buf1, FALSE); - /* * Now form an archive spec and recurse to deal with nested * variables and multi-word variable values.... The results * are just placed at the end of the nodeLst we're returning. */ + buf1 = Var_Subst(NULL, memName, ctxt, TRUE); + memName = Buf_GetAll(buf1, NULL); sz = strlen(memName) + strlen(libName) + 3; - buf = sacrifice = emalloc(sz); - + buf = emalloc(sz); snprintf(buf, sz, "%s(%s)", libName, memName); + sacrifice = buf; + if (strchr(memName, '$') && strcmp(memName, oldMemName) == 0) { /* * Must contain dynamic sources, so we can't deal with it now. @@ -296,6 +295,7 @@ Arch_ParseArchive(char **linePtr, Lst *n if (gn == NULL) { free(buf); + Buf_Destroy(buf1, FALSE); return (FAILURE); } else { gn->type |= OP_ARCHV; @@ -307,12 +307,14 @@ Arch_ParseArchive(char **linePtr, Lst *n * ourselves. */ free(buf); + Buf_Destroy(buf1, FALSE); return (FAILURE); } - /* - * Free buffer and continue with our work. - */ + + /* Free buffer and continue with our work. */ free(buf); + Buf_Destroy(buf1, FALSE); + } else if (Dir_HasWildcards(memName)) { Lst members = Lst_Initializer(members); char *member;