addinnetgrX may use the heap-allocated buffer, so free the buffer in this function. (cherry picked from commit 745664bd)