OSDN Git Service

Fix memory leak on realloc() failure.
authorrelan <relan@users.noreply.github.com>
Fri, 23 May 2014 19:24:13 +0000 (19:24 +0000)
committerrelan <relan@users.noreply.github.com>
Mon, 24 Aug 2015 05:26:16 +0000 (08:26 +0300)
In fact reallocf() would do the thing but unfortunetly it's non-standard.

fuse/main.c

index b9b412a..2f157c4 100644 (file)
@@ -379,6 +379,7 @@ static struct fuse_operations fuse_exfat_ops =
 static char* add_option(char* options, const char* name, const char* value)
 {
        size_t size;
+       char* optionsf = options;
 
        if (value)
                size = strlen(options) + strlen(name) + strlen(value) + 3;
@@ -388,6 +389,7 @@ static char* add_option(char* options, const char* name, const char* value)
        options = realloc(options, size);
        if (options == NULL)
        {
+               free(optionsf);
                exfat_error("failed to reallocate options string");
                return NULL;
        }