summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src
diff options
context:
space:
mode:
Diffstat (limited to 'libglusterfs/src')
-rw-r--r--libglusterfs/src/gf-dirent.c8
-rw-r--r--libglusterfs/src/syncop.c18
2 files changed, 23 insertions, 3 deletions
diff --git a/libglusterfs/src/gf-dirent.c b/libglusterfs/src/gf-dirent.c
index c602d08b278..3cbef6605db 100644
--- a/libglusterfs/src/gf-dirent.c
+++ b/libglusterfs/src/gf-dirent.c
@@ -177,7 +177,7 @@ gf_dirent_entry_free (gf_dirent_t *entry)
if (entry->inode)
inode_unref (entry->inode);
- list_del (&entry->list);
+ list_del_init (&entry->list);
GF_FREE (entry);
}
@@ -204,14 +204,20 @@ entry_copy (gf_dirent_t *source)
gf_dirent_t *sink = NULL;
sink = gf_dirent_for_name (source->d_name);
+ if (!sink)
+ return NULL;
sink->d_off = source->d_off;
sink->d_ino = source->d_ino;
sink->d_type = source->d_type;
sink->d_stat = source->d_stat;
+ sink->d_len = source->d_len;
if (source->inode)
sink->inode = inode_ref (source->inode);
+
+ if (source->dict)
+ sink->dict = dict_ref (source->dict);
return sink;
}
diff --git a/libglusterfs/src/syncop.c b/libglusterfs/src/syncop.c
index a4e39702b70..efcf2fcfb52 100644
--- a/libglusterfs/src/syncop.c
+++ b/libglusterfs/src/syncop.c
@@ -1239,6 +1239,12 @@ syncop_readdirp_cbk (call_frame_t *frame,
if (op_ret >= 0) {
list_for_each_entry (entry, &entries->list, list) {
tmp = entry_copy (entry);
+ if (!tmp) {
+ args->op_ret = -1;
+ args->op_errno = ENOMEM;
+ gf_dirent_free (&(args->entries));
+ break;
+ }
gf_log (this->name, GF_LOG_TRACE,
"adding entry=%s, count=%d",
tmp->d_name, count);
@@ -1269,7 +1275,8 @@ syncop_readdirp (xlator_t *subvol,
if (entries)
list_splice_init (&args.entries.list, &entries->list);
- /* TODO: need to free all the 'args.entries' in 'else' case */
+ else
+ gf_dirent_free (&args.entries);
if (xdata_out)
*xdata_out = args.xdata;
@@ -1308,6 +1315,12 @@ syncop_readdir_cbk (call_frame_t *frame,
if (op_ret >= 0) {
list_for_each_entry (entry, &entries->list, list) {
tmp = entry_copy (entry);
+ if (!tmp) {
+ args->op_ret = -1;
+ args->op_errno = ENOMEM;
+ gf_dirent_free (&(args->entries));
+ break;
+ }
gf_log (this->name, GF_LOG_TRACE,
"adding entry=%s, count=%d",
tmp->d_name, count);
@@ -1338,7 +1351,8 @@ syncop_readdir (xlator_t *subvol,
if (entries)
list_splice_init (&args.entries.list, &entries->list);
- /* TODO: need to free all the 'args.entries' in 'else' case */
+ else
+ gf_dirent_free (&args.entries);
if (xdata_out)
*xdata_out = args.xdata;