diff options
author | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2014-05-30 23:19:02 -0300 |
---|---|---|
committer | Felipe Oliveira Carvalho <felipekde@gmail.com> | 2014-06-16 01:36:31 -0300 |
commit | 81ca5ff126c5c0731b7eb57513f899ac6619073e (patch) | |
tree | 63784713d4e3abb32a7bf5a491a8e155171cbbce /src/nvim/mbyte.c | |
parent | 8234f2839f78009442b4ed7bc0599e6b581d5cf8 (diff) | |
download | rneovim-81ca5ff126c5c0731b7eb57513f899ac6619073e.tar.gz rneovim-81ca5ff126c5c0731b7eb57513f899ac6619073e.tar.bz2 rneovim-81ca5ff126c5c0731b7eb57513f899ac6619073e.zip |
No OOM in enc_canonize()
Fix a `return FAIL` that should be `return NULL` in `enc_locale()`
Diffstat (limited to 'src/nvim/mbyte.c')
-rw-r--r-- | src/nvim/mbyte.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c index 899b94e0fb..21fdd31db1 100644 --- a/src/nvim/mbyte.c +++ b/src/nvim/mbyte.c @@ -84,6 +84,7 @@ #include "nvim/charset.h" #include "nvim/cursor.h" #include "nvim/fileio.h" +#include "nvim/func_attr.h" #include "nvim/memline.h" #include "nvim/message.h" #include "nvim/misc1.h" @@ -3308,24 +3309,23 @@ char_u * enc_skip(char_u *p) * Find the canonical name for encoding "enc". * When the name isn't recognized, returns "enc" itself, but with all lower * case characters and '_' replaced with '-'. - * Returns an allocated string. NULL for out-of-memory. + * Returns an allocated string. */ -char_u * enc_canonize(char_u *enc) +char_u *enc_canonize(char_u *enc) FUNC_ATTR_NONNULL_RET { - char_u *r; char_u *p, *s; int i; if (STRCMP(enc, "default") == 0) { /* Use the default encoding as it's found by set_init_1(). */ - r = get_encoding_default(); + char_u *r = get_encoding_default(); if (r == NULL) r = (char_u *)"latin1"; return vim_strsave(r); } /* copy "enc" to allocated memory, with room for two '-' */ - r = xmalloc(STRLEN(enc) + 3); + char_u *r = xmalloc(STRLEN(enc) + 3); /* Make it all lower case and replace '_' with '-'. */ p = r; for (s = enc; *s != NUL; ++s) { @@ -3411,7 +3411,7 @@ char_u * enc_locale() s = (char *)os_getenv("LANG"); if (s == NULL || *s == NUL) - return FAIL; + return NULL; /* The most generic locale format is: * language[_territory][.codeset][@modifier][+special][,[sponsor][_revision]] |