mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-19 20:18:09 +00:00
Test if the filename of the lpconfig is not NULL before trying to read a relative file.
This commit is contained in:
parent
b6fac76880
commit
706ed3cfa1
1 changed files with 8 additions and 9 deletions
|
|
@ -696,18 +696,12 @@ const char* lp_config_get_default_string(const LpConfig *lpconfig, const char *s
|
|||
|
||||
static char *_lp_config_dirname(char *path) {
|
||||
#ifdef _MSC_VER
|
||||
#ifdef WINAPI_FAMILY_PHONE_APP
|
||||
char drive[_MAX_DRIVE];
|
||||
char dir[_MAX_DIR];
|
||||
char fname[_MAX_FNAME];
|
||||
char ext[_MAX_EXT];
|
||||
_splitpath(path, drive, dir, fname, ext);
|
||||
return ms_strdup_printf("%s%s", drive, dir);
|
||||
#else
|
||||
char *dir = ms_strdup(path);
|
||||
PathRemoveFileSpec(dir);
|
||||
return dir;
|
||||
#endif
|
||||
#else
|
||||
char *tmp = ms_strdup(path);
|
||||
char *dir = ms_strdup(dirname(tmp));
|
||||
|
|
@ -735,9 +729,14 @@ void lp_config_write_relative_file(const LpConfig *lpconfig, const char *filenam
|
|||
}
|
||||
|
||||
int lp_config_read_relative_file(const LpConfig *lpconfig, const char *filename, char *data, size_t max_length) {
|
||||
char *dir = _lp_config_dirname(lpconfig->filename);
|
||||
char *filepath = ms_strdup_printf("%s/%s", dir, filename);
|
||||
FILE *file = fopen(filepath, "r");
|
||||
char *dir;
|
||||
char *filepath;
|
||||
FILE *file;
|
||||
|
||||
if (lpconfig->filename == NULL) return -1;
|
||||
dir = _lp_config_dirname(lpconfig->filename);
|
||||
filepath = ms_strdup_printf("%s/%s", dir, filename);
|
||||
file = fopen(filepath, "r");
|
||||
if(file != NULL) {
|
||||
if(fread(data, 1, max_length, file)<=0) {
|
||||
ms_error("%s could not be loaded. %s", filepath, strerror(errno));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue