Ops, you're right, have a memleak:
```C
                        default:
                                p = strrchr(buf, '/');
                                if (!p) goto err;
                                *p = 0; // memleak here!!!
```


I'll fix it