Make sure that the hlink node->data allocation doesn't fail.
[rsync/rsync.git] / hlink.c
diff --git a/hlink.c b/hlink.c
index 0fe6bed..fede153 100644 (file)
--- a/hlink.c
+++ b/hlink.c
@@ -35,7 +35,7 @@ extern int remove_source_files;
 extern int stdout_format_has_i;
 extern int maybe_ATTRS_REPORT;
 extern int unsort_ndx;
-extern char *basis_dir[];
+extern char *basis_dir[MAX_BASIS_DIRS+1];
 extern struct file_list *cur_flist, *first_flist;
 
 #ifdef SUPPORT_HARD_LINKS
@@ -124,7 +124,8 @@ static void match_gnums(int32 *ndx_list, int ndx_count)
                if (inc_recurse) {
                        node = hashtable_find(prior_hlinks, gnum, 1);
                        if (!node->data) {
-                               node->data = new_array0(char, 5);
+                               if (!(node->data = new_array0(char, 5)))
+                                       out_of_memory("match_gnums");
                                assert(gnum >= hlink_flist->ndx_start);
                                file->flags |= FLAG_HLINK_FIRST;
                                prev = -1;
@@ -184,7 +185,7 @@ static void match_gnums(int32 *ndx_list, int ndx_count)
  * to first when we're done. */
 void match_hard_links(struct file_list *flist)
 {
-       if (!list_only) {
+       if (!list_only && flist->used) {
                int i, ndx_count = 0;
                int32 *ndx_list;