]> Sergey Matveev's repositories - nnn.git/commitdiff
fix incorrect usage of sizeof
authorNRK <nrk@disroot.org>
Wed, 1 Jun 2022 13:57:09 +0000 (19:57 +0600)
committerNRK <nrk@disroot.org>
Thu, 2 Jun 2022 09:44:31 +0000 (15:44 +0600)
`sizeof(cmd)` here would give the sizeof a char pointer, not the sizeof
the cp/mv array.

src/nnn.c

index 1465f4ab76291d8e976697cb55a39b02fb9cc88c..8500b783f0caf75250134442dff704f519def0af 100644 (file)
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2542,7 +2542,7 @@ static bool cpmv_rename(int choice, const char *path)
        uint_t count = 0, lines = 0;
        bool ret = FALSE;
        char *cmd = (choice == 'c' ? cp : mv);
-       char buf[sizeof(patterns[P_CPMVRNM]) + sizeof(cmd) + (PATH_MAX << 1)];
+       char buf[sizeof(patterns[P_CPMVRNM]) + (MAX(sizeof(cp), sizeof(mv))) + (PATH_MAX << 1)];
 
        fd = create_tmp_file();
        if (fd == -1)