]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Move a variable declaration closer to its use
authorVolker Lendecke <vl@samba.org>
Sun, 14 Sep 2025 17:48:08 +0000 (10:48 -0700)
committerRalph Boehme <slow@samba.org>
Tue, 21 Oct 2025 17:33:29 +0000 (17:33 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/smb1_nttrans.c

index c956e54760cbd87a8388df4186b9db6c509162ac..3539a9f8f03ab2ba4ee2742572c3f0208ba04ec3 100644 (file)
@@ -1424,7 +1424,6 @@ void reply_ntrename(struct smb_request *req)
        struct smb_filename *smb_fname_new = NULL;
        char *oldname = NULL;
        char *newname = NULL;
-       const char *dst_original_lcomp = NULL;
        const char *p;
        NTSTATUS status;
        uint32_t attrs;
@@ -1552,23 +1551,26 @@ void reply_ntrename(struct smb_request *req)
                }
        }
 
-       /* Get the last component of the destination for rename_internals(). */
-       dst_original_lcomp = get_original_lcomp(ctx,
-                                       conn,
-                                       newname,
-                                       ucf_flags_dst);
-       if (dst_original_lcomp == NULL) {
-               reply_nterror(req, NT_STATUS_NO_MEMORY);
-               goto out;
-       }
-
-
        DEBUG(3,("reply_ntrename: %s -> %s\n",
                 smb_fname_str_dbg(smb_fname_old),
                 smb_fname_str_dbg(smb_fname_new)));
 
        switch(rename_type) {
-       case RENAME_FLAG_RENAME:
+       case RENAME_FLAG_RENAME: {
+               /*
+                * Get the last component of the destination for
+                * rename_internals().
+                */
+
+               char *dst_original_lcomp = get_original_lcomp(ctx,
+                                                             conn,
+                                                             newname,
+                                                             ucf_flags_dst);
+               if (dst_original_lcomp == NULL) {
+                       reply_nterror(req, NT_STATUS_NO_MEMORY);
+                       goto out;
+               }
+
                status = rename_internals(ctx,
                                          conn,
                                          req,
@@ -1579,7 +1581,10 @@ void reply_ntrename(struct smb_request *req)
                                          attrs,
                                          false,
                                          DELETE_ACCESS);
+
+               TALLOC_FREE(dst_original_lcomp);
                break;
+       }
        case RENAME_FLAG_HARD_LINK:
                status = hardlink_internals(ctx,
                                            conn,