You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Getting error CID 262312: (#1 of 1): Resource leak (RESOURCE_LEAK)
5. leaked_storage: Variable stream going out of scope leaks the storage stream.state points to. in
'- (NSData *)gzippedDataWithCompressionLevel:(float)level' function while running Coverity scan tool.
Find the below code with comments(in bold) from Coverity tool
Getting error CID 262312: (#1 of 1): Resource leak (RESOURCE_LEAK)
5. leaked_storage: Variable stream going out of scope leaks the storage stream.state points to. in
'- (NSData *)gzippedDataWithCompressionLevel:(float)level' function while running Coverity scan tool.
Find the below code with comments(in bold) from Coverity tool
2- (NSData )gzippedDataWithCompressionLevel:(float)level
43{
1. Condition ({...; self->length(__coverity_objc_sel_name_length);}) == 0, taking false branch.
2. Condition self->isGzippedData(coverity_objc_sel_name_isGzippedData), taking false branch.
44 if (self.length == 0 || [self isGzippedData])
45 {
46 return self;
47 }
48
49 z_stream stream;
50 stream.zalloc = Z_NULL;
51 stream.zfree = Z_NULL;
52 stream.opaque = Z_NULL;
53 stream.avail_in = (uint)self.length;
54 stream.next_in = (Bytef *)(void *)self.bytes;
55 stream.total_out = 0;
56 stream.avail_out = 0;
57
58 static const NSUInteger ChunkSize = 16384;
59
60 NSMutableData *output = nil;
61 int compression = (level < 0.0f)? Z_DEFAULT_COMPRESSION: (int)(roundf(level * 9));
3. alloc_arg: deflateInit2 allocates memory that is stored into stream.state.
4. Condition deflateInit2(&stream, compression, 8, 31, 8, 0, "1.2.12" / "1.2.12" /, 112 / (int)sizeof (z_stream) */) == 0, taking false branch.
62 if (deflateInit2(&stream, compression, Z_DEFLATED, 31, 8, Z_DEFAULT_STRATEGY) == Z_OK)
63 {
64 output = [NSMutableData dataWithLength:ChunkSize];
65 while (stream.avail_out == 0)
66 {
67 if (stream.total_out >= output.length)
68 {
69 output.length += ChunkSize;
70 }
71 stream.next_out = (uint8_t *)output.mutableBytes + stream.total_out;
72 stream.avail_out = (uInt)(output.length - stream.total_out);
CID 239929:Unchecked return value from library (CHECKED_RETURN) [ "select issue" ]
73 deflate(&stream, Z_FINISH);
74 }
75 deflateEnd(&stream);
76 output.length = stream.total_out;
77 }
78
CID 262312: (#1 of 1): Resource leak (RESOURCE_LEAK)
5. leaked_storage: Variable stream going out of scope leaks the storage stream.state points to.
79 return output;
80}
The text was updated successfully, but these errors were encountered: