From 6d3d8a8f3df5af1f2c608b6ae8c41a62119ddc6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Grisez?= Date: Sun, 2 Aug 2015 23:16:10 +0200 Subject: [PATCH] Fix regression concerning the reading and the creation of .linphonerc The .linphonerc file was not created at the first launch of Linphone. The realpath function fails and returns NULL when passing a path which points on an empty file. --- coreapi/lpconfig.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/coreapi/lpconfig.c b/coreapi/lpconfig.c index 09889d06a..791823567 100644 --- a/coreapi/lpconfig.c +++ b/coreapi/lpconfig.c @@ -370,7 +370,15 @@ LpConfig *lp_config_new_with_factory(const char *config_filename, const char *fa LpConfig *lpconfig=lp_new0(LpConfig,1); lpconfig->refcnt=1; if (config_filename!=NULL){ - lpconfig->filename=lp_realpath(config_filename, NULL); + if(access(config_filename, F_OK) == 0) { + lpconfig->filename=lp_realpath(config_filename, NULL); + if(lpconfig->filename == NULL) { + ms_error("Could not find the real path of %s: %s", config_filename, strerror(errno)); + goto fail; + } + } else { + lpconfig->filename = ms_strdup(config_filename); + } lpconfig->tmpfilename=ortp_strdup_printf("%s.tmp",lpconfig->filename); ms_message("Using (r/w) config information from %s", lpconfig->filename); @@ -408,6 +416,10 @@ LpConfig *lp_config_new_with_factory(const char *config_filename, const char *fa lp_config_read_file(lpconfig, factory_config_filename); } return lpconfig; + +fail: + ms_free(lpconfig); + return NULL; } int lp_config_read_file(LpConfig *lpconfig, const char *filename){