When strdup is called in foo , the namestr variable value is overwritten, thereby losing the pointer to the memory allocated in main , and that causes the leak.
當strdup在foo中被調用,這個namestr變量值就會被覆寫,從而丟失main中內存分配的指針,導致滲漏。