This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
WIN32: update size after Renew
authorHugo van der Sanden <hv@crypt.org>
Tue, 28 Feb 2017 11:21:09 +0000 (11:21 +0000)
committerDavid Mitchell <davem@iabyn.com>
Wed, 15 Mar 2017 09:14:36 +0000 (09:14 +0000)
RT #130841

Setting it before Renew can cause problems if the Renew fails.

win32/win32.c
win32/wince.c

index 3981921..2e82c53 100644 (file)
@@ -968,8 +968,8 @@ win32_readdir(DIR *dirp)
                 * new name and its null terminator */
                while (newsize > dirp->size) {
                    long curpos = dirp->curr - dirp->start;
+                   Renew(dirp->start, dirp->size * 2, char);
                    dirp->size *= 2;
-                   Renew(dirp->start, dirp->size, char);
                    dirp->curr = dirp->start + curpos;
                }
                strcpy(dirp->start + endpos, buffer);
index 56a23b5..0458537 100644 (file)
@@ -765,8 +765,8 @@ win32_readdir(DIR *dirp)
                 * new name and its null terminator */
                while (newsize > dirp->size) {
                    long curpos = dirp->curr - dirp->start;
+                   Renew(dirp->start, dirp->size * 2, char);
                    dirp->size *= 2;
-                   Renew(dirp->start, dirp->size, char);
                    dirp->curr = dirp->start + curpos;
                }
                strcpy(dirp->start + endpos, ptr);