From 393792ff424dea52c46666c63502932f2da499e5 Mon Sep 17 00:00:00 2001
From: Vit Rosin <vit_r@list.ru>
Date: Sat, 20 Feb 2010 17:54:23 +0000
Subject: [PATCH] g_strdup of _vfs_get_cwd ()
as it is mentioned in lib/vfs/mc-vfs/vfs.c just before _vfs_get_cwd ()
{{{
You must g_strdup() whatever this function returns.
}}}
and a little bit alignments
---
lib/vfs/mc-vfs/vfs.c | 29 ++++++++++++++++-------------
1 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/lib/vfs/mc-vfs/vfs.c b/lib/vfs/mc-vfs/vfs.c
index 3f92269..1e7f71d 100644
a
|
b
|
vfs_split (char *path, char **inpath, char **op) |
305 | 305 | if (slash) |
306 | 306 | *slash = 0; |
307 | 307 | |
308 | | if ((ret = vfs_prefix_to_class (semi+1))){ |
309 | | if (op) |
| 308 | ret = vfs_prefix_to_class (semi + 1); |
| 309 | if (ret) { |
| 310 | if (op) |
310 | 311 | *op = semi + 1; |
311 | 312 | if (inpath) |
312 | 313 | *inpath = slash ? slash + 1 : NULL; |
… |
… |
mc_open (const char *filename, int flags, ...) |
559 | 560 | |
560 | 561 | info = (*vfs->open) (vfs, file, flags, mode); /* open must be supported */ |
561 | 562 | g_free (file); |
562 | | if (!info){ |
| 563 | if (!info) { |
563 | 564 | errno = ferrno (vfs); |
564 | 565 | return -1; |
565 | 566 | } |
… |
… |
_vfs_get_cwd (void) |
947 | 948 | if (!sys_cwd) |
948 | 949 | return current_dir; |
949 | 950 | |
950 | | /* Otherwise check if it is O.K. to use the current_dir */ |
951 | | if (!cd_symlinks || mc_stat (sys_cwd, &my_stat) |
952 | | || mc_stat (current_dir, &my_stat2) |
953 | | || my_stat.st_ino != my_stat2.st_ino |
954 | | || my_stat.st_dev != my_stat2.st_dev) { |
955 | | g_free (current_dir); |
| 951 | /* Otherwise check if it is O.K. to use the current_dir */ |
| 952 | if (!cd_symlinks || mc_stat (sys_cwd, &my_stat) |
| 953 | || mc_stat (current_dir, &my_stat2) |
| 954 | || my_stat.st_ino != my_stat2.st_ino |
| 955 | || my_stat.st_dev != my_stat2.st_dev) { |
| 956 | g_free (current_dir); |
956 | 957 | current_dir = sys_cwd; |
957 | 958 | return sys_cwd; |
958 | | }/* Otherwise we return current_dir below */ |
| 959 | } /* Otherwise we return current_dir below */ |
959 | 960 | } |
960 | | } |
| 961 | } |
961 | 962 | } |
962 | 963 | g_free (trans); |
963 | 964 | return current_dir; |
… |
… |
vfs_setup_wd (void) |
982 | 983 | char * |
983 | 984 | mc_get_current_wd (char *buffer, int size) |
984 | 985 | { |
985 | | const char *cwd = _vfs_get_cwd (); |
| 986 | const char *cwd = g_strdup (_vfs_get_cwd ()); |
| 987 | if (cwd == NULL) |
| 988 | return NULL; |
986 | 989 | |
987 | 990 | g_strlcpy (buffer, cwd, size); |
988 | 991 | return buffer; |
… |
… |
vfs_canon (const char *path) |
1028 | 1031 | vfs_die("Cannot canonicalize NULL"); |
1029 | 1032 | |
1030 | 1033 | /* Relative to current directory */ |
1031 | | if (*path != PATH_SEP){ |
| 1034 | if (*path != PATH_SEP) { |
1032 | 1035 | char *local, *result; |
1033 | 1036 | |
1034 | 1037 | local = concat_dir_and_file (current_dir, path); |