Fix two small issues

The first patch fixes a use-after-free, the second replaces a usage of strcat with a functionally identical usage of strncat.