ss_bsdiff: Fix to check memalloc fail case 09/314609/1
authorSangYoun Kwak <sy.kwak@samsung.com>
Tue, 16 Jul 2024 07:12:01 +0000 (16:12 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Tue, 16 Jul 2024 07:12:01 +0000 (16:12 +0900)
New memory is allocated but its result(success or fail) is not checked,
so it is fixed to check and exit if malloc is failed.

Change-Id: I4d9f0d30ccf84185f6292d0ae68ca7d735121657
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
bsdiff/ss_bsdiff.c

index 21472e63752bf4b8514f27b7e8fcad301c501328..2bcc1a7a5f64e0edf308c7ea84522335ff539063 100644 (file)
@@ -282,6 +282,8 @@ int create_patch(const char *old_file, const char *new_file, const char *temp_pa
 
        data.num_threads = MULTI_THREADING;
        data.new = (u_char **)malloc(sizeof(u_char *)*data.num_threads);
+       if (!data.new)
+               err(1, "Memory allocation error: thread list");
 
        /* Allocate oldsize+1 bytes instead of oldsize bytes to ensure
                that we never try to malloc(0) and get a NULL pointer */