Some fixes for cppcheck warns about

This is my first pullrequest for a project :)
I have tried to fix all bugs which cppcheck warns about it.
I have separated the fixes via commits ( i'm not sure if i did correct or not )
The explanations of bugs are in each commit but as a summary :

 	Missing initialization for some variables : 
The return statement uses d1 , d2 , d3 and d4 variables but the code
which initialize them inside a if statement and not always this
if statement is corrent. On the other hand these variables are using
for return statement and needed to be initialized. A trivial fix to
pervent some compilers will give build error.

 	Fixes a bug about trying to reach already deallocated / released memory:
The archive_string_conv type sc variable already freed via
free(sc)
on the other hand in second line we are tyring to free its subset via
free(sc->from_charset)
this will cause a problem because we couldn't reach sc after first
release.

 	Multiple Resource leaks fixed : 
Missing fcloses all around project. Mostly forgetten before return
statements.