diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-05-07 18:23:55 +0200 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-05-07 18:23:55 +0200 |
commit | 657a953d5d2807ed99eddf7b45a4dc46cef626d5 (patch) | |
tree | f5ea31172e10ef4409409064ceb5d8898022317c /src/input/input_file.c | |
parent | bbb2643bdcc8fb3d7f29c11e1344286b042535bf (diff) | |
download | xine-lib-657a953d5d2807ed99eddf7b45a4dc46cef626d5.tar.gz xine-lib-657a953d5d2807ed99eddf7b45a4dc46cef626d5.tar.bz2 |
Use strn?dup instead of alloc + strn?cpy.
Whenever an allocated memory area is immediately filled in with a
string through strcpy() or strncpy(), replace the calls with the
appropriate strn?dup().
Diffstat (limited to 'src/input/input_file.c')
-rw-r--r-- | src/input/input_file.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/input/input_file.c b/src/input/input_file.c index f07c9e93c..774f6b081 100644 --- a/src/input/input_file.c +++ b/src/input/input_file.c @@ -727,8 +727,9 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, xprintf (this->xine, XINE_VERBOSITY_DEBUG, "input_file: readlink() failed: %s\n", strerror(errno)); else { - dir_files[num_dir_files].link = (char *) xine_xmalloc(linksize + 1); - strncpy(dir_files[num_dir_files].link, linkbuf, linksize); + dir_files[num_dir_files].link = + strndup(linkbuf, linksize); + dir_files[num_dir_files].type |= get_file_type(dir_files[num_dir_files].link, current_dir, this->xine); } } @@ -763,9 +764,8 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, "input_file: readlink() failed: %s\n", strerror(errno)); } else { - hide_files[num_hide_files].link = (char *) - xine_xmalloc(linksize + 1); - strncpy(hide_files[num_hide_files].link, linkbuf, linksize); + hide_files[num_hide_files].link = + strndup(linkbuf, linksize); hide_files[num_hide_files].type |= get_file_type(hide_files[num_hide_files].link, current_dir, this->xine); } } @@ -796,9 +796,8 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen, "input_file: readlink() failed: %s\n", strerror(errno)); } else { - norm_files[num_norm_files].link = (char *) - xine_xmalloc(linksize + 1); - strncpy(norm_files[num_norm_files].link, linkbuf, linksize); + norm_files[num_norm_files].link = + strndup(linkbuf, linksize); norm_files[num_norm_files].type |= get_file_type(norm_files[num_norm_files].link, current_dir, this->xine); } } |