Use the err code returned
Free allocated memory correctly
Fix compile error by returning values properly
Fixed memory leaks, incorrect type in malloc, removed unused code.
Remove unused code
Remove unused code
Free allocated memory, use proper type in malloc, remove unused code
Remove unused code
Free memory proprely, use correct type in malloc
Free memory properly, use correct type in malloc, call strcat only if
the source is valid
Free memory properly, use correct type in malloc
Free memory properly, use correct type in malloc
Free memory properly, use correct type in malloc
Free memory properly, use correct type in malloc
Free memory properly, use correct type in malloc
Free memory properly, use correct type in malloc
Initialised variables to 0 that were read without initialising
Merge branch 'static_analysis_fixes'
Revert "Merge branch 'static_analysis_fixes'"

This reverts commit b6647abd646d32f92ff325e528bc4aca7707d880, reversing
changes made to 3ede1a146158db1c681cbeaa091684cbe638fc85.