diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-06-12 14:00:35 +0900 |
---|---|---|
committer | 卜部昌平 <shyouhei@ruby-lang.org> | 2020-06-29 11:05:41 +0900 |
commit | 70857ae1aa06c85f4c2366aed9a716dfa778ca1b (patch) | |
tree | 942d1e509ffa83c7566e66ce7c3a6616b8bb2a96 /dir.c | |
parent | 9c92dcf366d2f66a085bd23f0b4934415e1a15b2 (diff) |
glob_make_pattern: do not goto into a branch
I'm not necessarily against every goto in general, but jumping into a
branch is definitely a bad idea. Better refactor.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3247
Diffstat (limited to 'dir.c')
-rw-r--r-- | dir.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -1705,10 +1705,7 @@ glob_make_pattern(const char *p, const char *e, int flags, rb_encoding *enc) tmp = GLOB_ALLOC(struct glob_pattern); if (!tmp) { - error: - *tail = 0; - glob_free_pattern(list); - return 0; + goto error; } tmp->type = dirsep ? MATCH_DIR : MATCH_ALL; tmp->str = 0; @@ -1716,6 +1713,11 @@ glob_make_pattern(const char *p, const char *e, int flags, rb_encoding *enc) tmp->next = 0; return list; + + error: + *tail = 0; + glob_free_pattern(list); + return 0; } static void |