Correct usage of realloc in gnc_xml_be_get_file_lock

This patch fixes a common mistake where the return value of the function call is set to the passed buffer and therefore previous allocated memory is lost if the realloc call fails. Therefore a temporary variable is introduced and the memory will be freed if the reallocation fails. In addition the return value of the malloc allocation is checked.