comparison src/message.c @ 17797:ec1717981acf v8.1.1895

patch 8.1.1895: using NULL pointer when out of memory commit https://github.com/vim/vim/commit/6f10c70b59fa4e56aa479345fb0caeaac7429bfb Author: Bram Moolenaar <Bram@vim.org> Date: Tue Aug 20 22:58:37 2019 +0200 patch 8.1.1895: using NULL pointer when out of memory Problem: Using NULL pointer when out of memory. Solution: Bail out or skip the code using the pointer. (Zu-Ming Jiang, closes #4805, closes #4843, closes #4939, closes #4844)
author Bram Moolenaar <Bram@vim.org>
date Tue, 20 Aug 2019 23:00:04 +0200
parents 0f7ae8010787
children 46f95606b9ec
comparison
equal deleted inserted replaced
17796:9ebba5c49827 17797:ec1717981acf
2586 if (*s == NL) 2586 if (*s == NL)
2587 { 2587 {
2588 int n = (int)(s - p); 2588 int n = (int)(s - p);
2589 2589
2590 buf = alloc(n + 3); 2590 buf = alloc(n + 3);
2591 memcpy(buf, p, n); 2591 if (buf != NULL)
2592 if (!info_message) 2592 {
2593 buf[n++] = CAR; 2593 memcpy(buf, p, n);
2594 buf[n++] = NL; 2594 if (!info_message)
2595 buf[n++] = NUL; 2595 buf[n++] = CAR;
2596 if (info_message) // informative message, not an error 2596 buf[n++] = NL;
2597 mch_msg((char *)buf); 2597 buf[n++] = NUL;
2598 else 2598 if (info_message) // informative message, not an error
2599 mch_errmsg((char *)buf); 2599 mch_msg((char *)buf);
2600 vim_free(buf); 2600 else
2601 mch_errmsg((char *)buf);
2602 vim_free(buf);
2603 }
2601 p = s + 1; 2604 p = s + 1;
2602 } 2605 }
2603 } 2606 }
2604 2607
2605 // primitive way to compute the current column 2608 // primitive way to compute the current column