From 52b383e01b4cf9ad409a54f3988421dc63f8bb0e Mon Sep 17 00:00:00 2001 From: Damiano Galassi Date: Mon, 10 Mar 2025 10:18:40 +0100 Subject: [PATCH] Fix a clang static analyzer warning --- MP42/MP42AACImporter.mm | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/MP42/MP42AACImporter.mm b/MP42/MP42AACImporter.mm index 3232923..a929272 100644 --- a/MP42/MP42AACImporter.mm +++ b/MP42/MP42AACImporter.mm @@ -811,15 +811,19 @@ static bool GetFirstHeader(FILE* inFile) samplesPerSecond, channelConfig); - newTrack.timescale = samplesPerSecond; - newTrack.channels = channelConfig; - newTrack.dataLength = [[[NSFileManager.defaultManager attributesOfItemAtPath:self.fileURL.path error:nil] valueForKey:NSFileSize] unsignedLongLongValue]; + if (pConfig) { + newTrack.timescale = samplesPerSecond; + newTrack.channels = channelConfig; + newTrack.dataLength = [[[NSFileManager.defaultManager attributesOfItemAtPath:self.fileURL.path error:nil] valueForKey:NSFileSize] unsignedLongLongValue]; - aacInfo = [[NSMutableData alloc] init]; - [aacInfo appendBytes:pConfig length:configLength]; - free(pConfig); + aacInfo = [[NSMutableData alloc] init]; + [aacInfo appendBytes:pConfig length:configLength]; + free(pConfig); - [self addTrack:newTrack]; + [self addTrack:newTrack]; + } else { + return nil; + } } return self;