OSDN Git Service

Add check of malloc() return value.
authorrelan <relan@users.noreply.github.com>
Thu, 17 Sep 2009 18:50:06 +0000 (18:50 +0000)
committerrelan <relan@users.noreply.github.com>
Mon, 24 Aug 2015 05:26:09 +0000 (08:26 +0300)
libexfat/lookup.c

index a125895..4aa46b1 100644 (file)
@@ -147,6 +147,12 @@ int exfat_readdir(struct exfat* ef, struct exfat_node* node,
                                return -EIO;
                        }
                        ef->upcase = malloc(le64_to_cpu(upcase->size));
+                       if (ef->upcase == NULL)
+                       {
+                               exfat_error("failed to allocate upcase table (%"PRIu64" bytes)",
+                                               le64_to_cpu(upcase->size));
+                               return -ENOMEM;
+                       }
                        ef->upcase_chars = le64_to_cpu(upcase->size) / sizeof(le16_t);
 
                        /* set up a few fields in node just to satisfy exfat_read() */