cgo: free allocated memory
cgo: free allocated memory

Well it is surprising that this bug didn't blow up in our face before. A couple
things:

- the pointer returned by dirname() is not allowed to be free()ed
  (See man 3 dirname)
- strdup() was not checked for NULL
- strdup() and dirname() assigned to the same variable
- Even though the pointer returned by dirname() was not supposed to be free()ed
  we were lucky enough to not be bitten by this since the free() call was
  basically a noop thanks to the switch statement.

Do none of these things!

Signed-off-by: Christian Brauner <48455ab3070520a2d174545c7239d6d0fabd9a83@ubuntu.com>

mjeanson/lxd,jsavikko/lxd,pcdummy/lxd,mjeanson/lxd,atxwebs/lxd,hallyn/lxd,lxc/lxd,Skarlso/lxd,lxc/lxd,lxc/lxd,Skarlso/lxd,stgraber/lxd,techtonik/lxd,jsavikko/lxd,stgraber/lxd,lxc/lxd,stgraber/lxd,atxwebs/lxd,hallyn/lxd,erikmack/lxd,pcdummy/lxd,atxwebs/lxd,lxc/lxd,lxc/lxd,atxwebs/lxd,erikmack/lxd,georghopp/lxd,mjeanson/lxd,georghopp/lxd,jsavikko/lxd,hallyn/lxd,hallyn/lxd,stgraber/lxd,Skarlso/lxd,Skarlso/lxd,techtonik/lxd,erikmack/lxd,georghopp/lxd,stgraber/lxd,stgraber/lxd,pcdummy/lxd,techtonik/lxd,lxc/lxd,hallyn/lxd,hallyn/lxd,stgraber/lxd