ruby-changes:58228
From: Yusuke <ko1@a...>
Date: Sun, 13 Oct 2019 00:54:05 +0900 (JST)
Subject: [ruby-changes:58228] a5ecf7e0a1 (master): dir.c (join_path_from_pattern): check NULL from malloc
https://git.ruby-lang.org/ruby.git/commit/?id=a5ecf7e0a1 From a5ecf7e0a165dff1b4604f1ed75a677c690488df Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Sun, 13 Oct 2019 00:51:50 +0900 Subject: dir.c (join_path_from_pattern): check NULL from malloc Coverity Scan points out that all the return values of GLOB_ALLOC_N are NULL-checked except this call. diff --git a/dir.c b/dir.c index e98fa25..5221490 100644 --- a/dir.c +++ b/dir.c @@ -2072,8 +2072,10 @@ join_path_from_pattern(struct glob_pattern **beg) https://github.com/ruby/ruby/blob/trunk/dir.c#L2072 if (!path) { path_len = strlen(str); path = GLOB_ALLOC_N(char, path_len + 1); - memcpy(path, str, path_len); - path[path_len] = '\0'; + if (path) { + memcpy(path, str, path_len); + path[path_len] = '\0'; + } } else { size_t len = strlen(str); -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/