From 9b0ac229bcfc91acabd35fc576055a94c1687c32 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 1 Jun 2016 20:31:43 +0200 Subject: [PATCH 1/6] patch 7.4.1863 Problem: Compiler warnings on Win64. Solution: Adjust types, add type casts. (Ken Takata) --- src/if_mzsch.c | 6 +++--- src/if_perl.xs | 7 ++++--- src/if_ruby.c | 2 +- src/version.c | 4 +++- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/if_mzsch.c b/src/if_mzsch.c index 93e4b6cbba..1861df49a0 100644 --- a/src/if_mzsch.c +++ b/src/if_mzsch.c @@ -545,7 +545,7 @@ static void (*dll_scheme_set_config_path)(Scheme_Object *p); # if MZSCHEME_VERSION_MAJOR >= 500 # if defined(IMPLEMENT_THREAD_LOCAL_VIA_WIN_TLS) || defined(IMPLEMENT_THREAD_LOCAL_EXTERNALLY_VIA_PROC) -/* define as function for macro in schshread.h */ +/* define as function for macro in schthread.h */ Thread_Local_Variables * scheme_external_get_thread_local_variables(void) { @@ -894,7 +894,7 @@ static void remove_timer(void); /* timers are presented in GUI only */ # if defined(FEAT_GUI_W32) static void CALLBACK -timer_proc(HWND hwnd UNUSED, UINT uMsg UNUSED, UINT idEvent UNUSED, DWORD dwTime UNUSED) +timer_proc(HWND hwnd UNUSED, UINT uMsg UNUSED, UINT_PTR idEvent UNUSED, DWORD dwTime UNUSED) # elif defined(FEAT_GUI_GTK) # if GTK_CHECK_VERSION(3,0,0) static gboolean @@ -3571,7 +3571,7 @@ raise_vim_exn(const char *add_info) info = scheme_make_byte_string(add_info); MZ_GC_CHECK(); - c_string = scheme_format_utf8(fmt, STRLEN(fmt), 1, &info, NULL); + c_string = scheme_format_utf8(fmt, (int)STRLEN(fmt), 1, &info, NULL); MZ_GC_CHECK(); byte_string = scheme_make_byte_string(c_string); MZ_GC_CHECK(); diff --git a/src/if_perl.xs b/src/if_perl.xs index aab7ade227..a4899945fe 100644 --- a/src/if_perl.xs +++ b/src/if_perl.xs @@ -1075,7 +1075,8 @@ perl_to_vim(SV *sv, typval_T *rettv) { size_t len = 0; char * str_from = SvPV(sv, len); - char_u *str_to = (char_u*)alloc(sizeof(char_u) * (len + 1)); + char_u *str_to = (char_u*)alloc( + (unsigned)(sizeof(char_u) * (len + 1))); if (str_to) { str_to[len] = '\0'; @@ -1370,13 +1371,13 @@ PerlIOVim_write(pTHX_ PerlIO *f, const void *vbuf, Size_t count) char_u *str; PerlIOVim * s = PerlIOSelf(f, PerlIOVim); - str = vim_strnsave((char_u *)vbuf, count); + str = vim_strnsave((char_u *)vbuf, (int)count); if (str == NULL) return 0; msg_split((char_u *)str, s->attr); vim_free(str); - return count; + return (SSize_t)count; } static PERLIO_FUNCS_DECL(PerlIO_Vim) = { diff --git a/src/if_ruby.c b/src/if_ruby.c index 80ffa49d31..90e814ec12 100644 --- a/src/if_ruby.c +++ b/src/if_ruby.c @@ -733,7 +733,7 @@ vim_str2rb_enc_str(const char *s) vim_free(sval); if (enc) { - return rb_enc_str_new(s, strlen(s), enc); + return rb_enc_str_new(s, (long)strlen(s), enc); } } #endif diff --git a/src/version.c b/src/version.c index 279ee6d396..0d234a5d3d 100644 --- a/src/version.c +++ b/src/version.c @@ -753,6 +753,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1863, /**/ 1862, /**/ @@ -5077,7 +5079,7 @@ do_intro_line( if (*mesg == ' ') { vim_strncpy(modby, (char_u *)_("Modified by "), MODBY_LEN - 1); - l = STRLEN(modby); + l = (int)STRLEN(modby); vim_strncpy(modby + l, (char_u *)MODIFIED_BY, MODBY_LEN - l - 1); mesg = modby; } From 22081f4a3397704645841121d994058abd6cb481 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 1 Jun 2016 20:38:34 +0200 Subject: [PATCH 2/6] patch 7.4.1864 Problem: Python: encoding error with Python 2. Solution: Use "getcwdu" instead of "getcwd". (Ken Takata) --- src/if_py_both.h | 5 +++++ src/version.c | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/if_py_both.h b/src/if_py_both.h index ce8bacd852..50fd687d96 100644 --- a/src/if_py_both.h +++ b/src/if_py_both.h @@ -6770,8 +6770,13 @@ populate_module(PyObject *m) return -1; ADD_OBJECT(m, "os", other_module); +#if PY_MAJOR_VERSION >= 3 if (!(py_getcwd = PyObject_GetAttrString(other_module, "getcwd"))) return -1; +#else + if (!(py_getcwd = PyObject_GetAttrString(other_module, "getcwdu"))) + return -1; +#endif ADD_OBJECT(m, "_getcwd", py_getcwd) if (!(py_chdir = PyObject_GetAttrString(other_module, "chdir"))) diff --git a/src/version.c b/src/version.c index 0d234a5d3d..a934fe72e6 100644 --- a/src/version.c +++ b/src/version.c @@ -753,6 +753,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1864, /**/ 1863, /**/ From 9ad73239c26467832a5b553b2a4b99d7ffbaa25e Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 1 Jun 2016 22:08:17 +0200 Subject: [PATCH 3/6] patch 7.4.1865 Problem: Memory leaks in tet49. (Dominique Pelle) Solution: Use NULL instead of an empty string. --- src/eval.c | 2 +- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/eval.c b/src/eval.c index adfe8f899a..3d0abf3692 100644 --- a/src/eval.c +++ b/src/eval.c @@ -5298,7 +5298,7 @@ eval7( * what follows. So set it here. */ if (rettv->v_type == VAR_UNKNOWN && !evaluate && **arg == '(') { - rettv->vval.v_string = vim_strsave((char_u *)""); + rettv->vval.v_string = NULL; rettv->v_type = VAR_FUNC; } diff --git a/src/version.c b/src/version.c index a934fe72e6..7952a140c5 100644 --- a/src/version.c +++ b/src/version.c @@ -753,6 +753,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1865, /**/ 1864, /**/ From a96732150cda2f242133228579b05437a39b8daa Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 1 Jun 2016 22:21:06 +0200 Subject: [PATCH 4/6] patch 7.4.1866 Problem: Invalid memory access when exiting with EXITFREE defined. (Dominique Pelle) Solution: Set "really_exiting" and skip error messages. --- src/eval.c | 6 +++++- src/misc2.c | 3 +++ src/version.c | 2 ++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/eval.c b/src/eval.c index 3d0abf3692..a49d54bd05 100644 --- a/src/eval.c +++ b/src/eval.c @@ -25348,7 +25348,11 @@ func_unref(char_u *name) { fp = find_func(name); if (fp == NULL) - EMSG2(_(e_intern2), "func_unref()"); + { + /* Ignore when invoked through free_all_mem(). */ + if (!really_exiting) + EMSG2(_(e_intern2), "func_unref()"); + } else if (--fp->uf_refcount <= 0) { /* Only delete it when it's not being used. Otherwise it's done diff --git a/src/misc2.c b/src/misc2.c index b4e94795f1..f7b1de30d5 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -1044,6 +1044,9 @@ free_all_mem(void) return; entered = TRUE; + /* Set this flag to indicate some errors can be ignored. */ + really_exiting = TRUE; + # ifdef FEAT_AUTOCMD /* Don't want to trigger autocommands from here on. */ block_autocmds(); diff --git a/src/version.c b/src/version.c index 7952a140c5..f9305d515f 100644 --- a/src/version.c +++ b/src/version.c @@ -753,6 +753,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1866, /**/ 1865, /**/ From 3c809343c72d9964475f421fd03bb892bc584a51 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 1 Jun 2016 22:34:48 +0200 Subject: [PATCH 5/6] patch 7.4.1867 Problem: Memory leak in test_matchstrpos. Solution: Free the string before overwriting. (Yegappan Lakshmanan) --- src/eval.c | 1 + src/version.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/eval.c b/src/eval.c index a49d54bd05..7b8a0ae958 100644 --- a/src/eval.c +++ b/src/eval.c @@ -15773,6 +15773,7 @@ find_some_match(typval_T *argvars, typval_T *rettv, int type) listitem_T *li3 = li2->li_next; listitem_T *li4 = li3->li_next; + vim_free(li1->li_tv.vval.v_string); li1->li_tv.vval.v_string = vim_strnsave(regmatch.startp[0], (int)(regmatch.endp[0] - regmatch.startp[0])); li3->li_tv.vval.v_number = diff --git a/src/version.c b/src/version.c index f9305d515f..8980b2d3d3 100644 --- a/src/version.c +++ b/src/version.c @@ -753,6 +753,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1867, /**/ 1866, /**/ From b89a25f17e274dc308c584ea69a129ffbb26bc3d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 1 Jun 2016 23:08:39 +0200 Subject: [PATCH 6/6] patch 7.4.1868 Problem: Setting really_exiting causes memory leaks to be reported. Solution: Add the in_free_all_mem flag. --- src/eval.c | 5 +++-- src/globals.h | 4 ++++ src/misc2.c | 8 ++------ src/version.c | 2 ++ 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/eval.c b/src/eval.c index 7b8a0ae958..50d1cbae8c 100644 --- a/src/eval.c +++ b/src/eval.c @@ -25350,8 +25350,9 @@ func_unref(char_u *name) fp = find_func(name); if (fp == NULL) { - /* Ignore when invoked through free_all_mem(). */ - if (!really_exiting) +#ifdef EXITFREE + if (!entered_free_all_mem) +#endif EMSG2(_(e_intern2), "func_unref()"); } else if (--fp->uf_refcount <= 0) diff --git a/src/globals.h b/src/globals.h index 5010cd4aee..369eb546ec 100644 --- a/src/globals.h +++ b/src/globals.h @@ -635,6 +635,10 @@ EXTERN int exiting INIT(= FALSE); EXTERN int really_exiting INIT(= FALSE); /* TRUE when we are sure to exit, e.g., after * a deadly signal */ +#if defined(EXITFREE) +EXTERN int entered_free_all_mem INIT(= FALSE); + /* TRUE when in or after free_all_mem() */ +#endif /* volatile because it is used in signal handler deathtrap(). */ EXTERN volatile int full_screen INIT(= FALSE); /* TRUE when doing full-screen output diff --git a/src/misc2.c b/src/misc2.c index f7b1de30d5..ae6ca048d9 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -1036,16 +1036,12 @@ static void free_findfile(void); free_all_mem(void) { buf_T *buf, *nextbuf; - static int entered = FALSE; /* When we cause a crash here it is caught and Vim tries to exit cleanly. * Don't try freeing everything again. */ - if (entered) + if (entered_free_all_mem) return; - entered = TRUE; - - /* Set this flag to indicate some errors can be ignored. */ - really_exiting = TRUE; + entered_free_all_mem = TRUE; # ifdef FEAT_AUTOCMD /* Don't want to trigger autocommands from here on. */ diff --git a/src/version.c b/src/version.c index 8980b2d3d3..ea586106a3 100644 --- a/src/version.c +++ b/src/version.c @@ -753,6 +753,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1868, /**/ 1867, /**/