Mercurial > vim
comparison src/userfunc.c @ 20542:dd3165956464 v8.2.0825
patch 8.2.0825: def_function() may return pointer that was freed
Commit: https://github.com/vim/vim/commit/a14e6975478adeddcc2161edc1ec611016aa89f3
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon May 25 23:29:28 2020 +0200
patch 8.2.0825: def_function() may return pointer that was freed
Problem: def_function() may return pointer that was freed.
Solution: Set "fp" to NULL after freeing it.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 25 May 2020 23:30:03 +0200 |
parents | 9f921ba86d05 |
children | e8132bec4b0f |
comparison
equal
deleted
inserted
replaced
20541:fa41a7fbaf5c | 20542:dd3165956464 |
---|---|
3138 // add new dict entry | 3138 // add new dict entry |
3139 fudi.fd_di = dictitem_alloc(fudi.fd_newkey); | 3139 fudi.fd_di = dictitem_alloc(fudi.fd_newkey); |
3140 if (fudi.fd_di == NULL) | 3140 if (fudi.fd_di == NULL) |
3141 { | 3141 { |
3142 vim_free(fp); | 3142 vim_free(fp); |
3143 fp = NULL; | |
3143 goto erret; | 3144 goto erret; |
3144 } | 3145 } |
3145 if (dict_add(fudi.fd_dict, fudi.fd_di) == FAIL) | 3146 if (dict_add(fudi.fd_dict, fudi.fd_di) == FAIL) |
3146 { | 3147 { |
3147 vim_free(fudi.fd_di); | 3148 vim_free(fudi.fd_di); |
3148 vim_free(fp); | 3149 vim_free(fp); |
3150 fp = NULL; | |
3149 goto erret; | 3151 goto erret; |
3150 } | 3152 } |
3151 } | 3153 } |
3152 else | 3154 else |
3153 // overwrite existing dict entry | 3155 // overwrite existing dict entry |
3167 hi->hi_key = UF2HIKEY(fp); | 3169 hi->hi_key = UF2HIKEY(fp); |
3168 } | 3170 } |
3169 else if (hash_add(&func_hashtab, UF2HIKEY(fp)) == FAIL) | 3171 else if (hash_add(&func_hashtab, UF2HIKEY(fp)) == FAIL) |
3170 { | 3172 { |
3171 vim_free(fp); | 3173 vim_free(fp); |
3174 fp = NULL; | |
3172 goto erret; | 3175 goto erret; |
3173 } | 3176 } |
3174 fp->uf_refcount = 1; | 3177 fp->uf_refcount = 1; |
3175 } | 3178 } |
3176 fp->uf_args = newargs; | 3179 fp->uf_args = newargs; |