mkdir calls strdup on the dir that's passed in, but doesn't account for
allocation failure. Have it return -ENOMEM in that case.

Signed-off-by: Ahmad Fatoum <[email protected]>
---
 lib/make_directory.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/make_directory.c b/lib/make_directory.c
index 7db93ded8817..59ac87e6bfdf 100644
--- a/lib/make_directory.c
+++ b/lib/make_directory.c
@@ -19,6 +19,9 @@ STATIC int make_directory(const char *dir)
        char c;
        int ret = 0;
 
+       if (!s)
+               return -ENOMEM;
+
        do {
                c = 0;
 
-- 
2.39.2


Reply via email to