Mercurial > vim
diff src/crypt_zip.c @ 16429:a1229400434a v8.1.1219
patch 8.1.1219: not checking for NULL return from alloc()
commit https://github.com/vim/vim/commit/6ee9658774942f7448af700fc04df0335796a3db
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Apr 27 22:06:37 2019 +0200
patch 8.1.1219: not checking for NULL return from alloc()
Problem: Not checking for NULL return from alloc().
Solution: Add checks. (Martin Kunev, closes https://github.com/vim/vim/issues/4303, closes https://github.com/vim/vim/issues/4174)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 27 Apr 2019 22:15:05 +0200 |
parents | cd5c83115ec6 |
children | ce04ebdf26b8 |
line wrap: on
line diff
--- a/src/crypt_zip.c +++ b/src/crypt_zip.c @@ -78,7 +78,7 @@ make_crc_tab(void) /* * Initialize for encryption/decryption. */ - void + int crypt_zip_init( cryptstate_T *state, char_u *key, @@ -91,6 +91,8 @@ crypt_zip_init( zip_state_T *zs; zs = (zip_state_T *)alloc(sizeof(zip_state_T)); + if (zs == NULL) + return FAIL; state->method_state = zs; make_crc_tab(); @@ -99,6 +101,8 @@ crypt_zip_init( zs->keys[2] = 878082192L; for (p = key; *p != NUL; ++p) UPDATE_KEYS_ZIP(zs->keys, (int)*p); + + return OK; } /*