Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
BC
public
liblinphone
Commits
706ed3cf
Commit
706ed3cf
authored
Mar 23, 2015
by
Ghislain MARY
Browse files
Test if the filename of the lpconfig is not NULL before trying to read a relative file.
parent
b6fac768
Changes
1
Hide whitespace changes
Inline
Side-by-side
coreapi/lpconfig.c
View file @
706ed3cf
...
...
@@ -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
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment