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 #4303, closes #4174)
diff --git a/src/blowfish.c b/src/blowfish.c
index 7bc3e31..ce49957 100644
--- a/src/blowfish.c
+++ b/src/blowfish.c
@@ -636,7 +636,7 @@
}
}
- void
+ int
crypt_blowfish_init(
cryptstate_T *state,
char_u* key,
@@ -647,6 +647,8 @@
{
bf_state_T *bfs = (bf_state_T *)alloc_clear(sizeof(bf_state_T));
+ if (bfs == NULL)
+ return FAIL;
state->method_state = bfs;
/* "blowfish" uses a 64 byte buffer, causing it to repeat 8 byte groups 8
@@ -654,10 +656,12 @@
bfs->cfb_len = state->method_nr == CRYPT_M_BF ? BF_MAX_CFB_LEN : BF_BLOCK;
if (blowfish_self_test() == FAIL)
- return;
+ return FAIL;
bf_key_init(bfs, key, salt, salt_len);
bf_cfb_init(bfs, seed, seed_len);
+
+ return OK;
}
/*