updated for version 7.4.139
Problem:    Crash when using :cd in autocommand. (François Ingelrest)
Solution:   Set w_localdir to NULL after freeing it. (Dominique Pelle)
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index bf5f81c..17c5606 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -8228,6 +8228,7 @@
     int		local;
 {
     vim_free(curwin->w_localdir);
+    curwin->w_localdir = NULL;
     if (local)
     {
 	/* If still in global directory, need to remember current
@@ -8244,7 +8245,6 @@
 	 * name. */
 	vim_free(globaldir);
 	globaldir = NULL;
-	curwin->w_localdir = NULL;
     }
 
     shorten_fnames(TRUE);
diff --git a/src/version.c b/src/version.c
index 1fda7d5..d8c0123 100644
--- a/src/version.c
+++ b/src/version.c
@@ -739,6 +739,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    139,
+/**/
     138,
 /**/
     137,
diff --git a/src/window.c b/src/window.c
index 48745f0..66cee28 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1216,8 +1216,8 @@
     else
 	copy_loclist(oldp, newp);
 #endif
-    if (oldp->w_localdir != NULL)
-	newp->w_localdir = vim_strsave(oldp->w_localdir);
+    newp->w_localdir = (oldp->w_localdir == NULL)
+				    ? NULL : vim_strsave(oldp->w_localdir);
 
     /* copy tagstack and folds */
     for (i = 0; i < oldp->w_tagstacklen; i++)