fs/squashfs: sqfs_concat_tokens: check if malloc succeeds 72/250872/1
authorRichard Genoud <richard.genoud@posteo.net>
Tue, 3 Nov 2020 11:11:08 +0000 (12:11 +0100)
committerJaehoon Chung <jh80.chung@samsung.com>
Tue, 5 Jan 2021 07:07:10 +0000 (16:07 +0900)
memory allocation should always be checked

Reviewed-by: Joao Marcos Costa <jmcosta944@gmail.com>
Signed-off-by: Richard Genoud <richard.genoud@posteo.net>
[jh80.chung: cherry picked from mainline commit dc3312c43c82ff9335b2bf4ee4f72365e824adfd]
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
Change-Id: I160a321fe56fc63476d19adbbaa62129daa03f79

fs/squashfs/sqfs.c

index 620a6adaed8f38b585e3ee472bbb3e84cf046b72..f4ecb0801dc26f575917a4dcd2b3ca17f2e57c66 100644 (file)
@@ -242,6 +242,9 @@ static char *sqfs_concat_tokens(char **token_list, int token_count)
        length = sqfs_get_tokens_length(token_list, token_count);
 
        result = malloc(length + 1);
+       if (!result)
+               return NULL;
+
        result[length] = '\0';
 
        for (i = 0; i < token_count; i++) {