Commit 81df3b51 81df3b518fbf75717b4013126e200ee0c256e244 by Sergey Poznyakoff

(mh_file_to_message): Fix a memory leak

1 parent 7125b13c
...@@ -638,16 +638,13 @@ mh_file_copy (const char *from, const char *to) ...@@ -638,16 +638,13 @@ mh_file_copy (const char *from, const char *to)
638 return rc; 638 return rc;
639 } 639 }
640 640
641 mu_message_t 641 static mu_message_t
642 mh_file_to_message (const char *folder, char *file_name) 642 _file_to_message (char *file_name)
643 { 643 {
644 struct stat st; 644 struct stat st;
645 int rc; 645 int rc;
646 mu_stream_t instream; 646 mu_stream_t instream;
647 647
648 if (folder)
649 file_name = mh_expand_name (folder, file_name, 0);
650
651 if (stat (file_name, &st) < 0) 648 if (stat (file_name, &st) < 0)
652 { 649 {
653 mu_error (_("Cannot stat file %s: %s"), file_name, strerror (errno)); 650 mu_error (_("Cannot stat file %s: %s"), file_name, strerror (errno));
...@@ -672,6 +669,24 @@ mh_file_to_message (const char *folder, char *file_name) ...@@ -672,6 +669,24 @@ mh_file_to_message (const char *folder, char *file_name)
672 return mh_stream_to_message (instream); 669 return mh_stream_to_message (instream);
673 } 670 }
674 671
672 mu_message_t
673 mh_file_to_message (const char *folder, char *file_name)
674 {
675 mu_message_t msg;
676 char *tmp_name = NULL;
677
678 if (folder)
679 {
680 tmp_name = mh_expand_name (folder, file_name, 0);
681 msg = _file_to_message (tmp_name);
682 free (tmp_name);
683 }
684 else
685 msg = _file_to_message (file_name);
686
687 return msg;
688 }
689
675 void 690 void
676 mh_install_help (char *mhdir) 691 mh_install_help (char *mhdir)
677 { 692 {
......