From bc8c004c955660925f29dc86bfe1815ed5543f88 Mon Sep 17 00:00:00 2001 From: TYPCN Date: Tue, 2 Aug 2016 01:34:29 +0800 Subject: [PATCH] Fix memory leaks --- AirPlay/reverseHTTP.cpp | 3 +-- bilibili/Info.plist | 2 +- bilibili/Player/PlayerView.mm | 14 +++++++------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/AirPlay/reverseHTTP.cpp b/AirPlay/reverseHTTP.cpp index 1869c63..4ba649b 100644 --- a/AirPlay/reverseHTTP.cpp +++ b/AirPlay/reverseHTTP.cpp @@ -27,7 +27,7 @@ PTTH::PTTH() bool PTTH::conn(const char *address) { - char *addr_chr = (char *)malloc(strlen(address)+1); + char addr_chr[strlen(address) + 1]; strcpy(addr_chr,address); char *addr_hostname = strtok(addr_chr, ":"); @@ -67,7 +67,6 @@ bool PTTH::conn(const char *address) } printf("[PTTH] %s Connected\n",addr_port); - free(addr_chr); return true; } diff --git a/bilibili/Info.plist b/bilibili/Info.plist index 008f047..1399428 100644 --- a/bilibili/Info.plist +++ b/bilibili/Info.plist @@ -233,7 +233,7 @@ CFBundleVersion - 3083 + 3088 Fabric APIKey diff --git a/bilibili/Player/PlayerView.mm b/bilibili/Player/PlayerView.mm index cc27824..714b347 100644 --- a/bilibili/Player/PlayerView.mm +++ b/bilibili/Player/PlayerView.mm @@ -386,17 +386,17 @@ - (NSDictionary *) getVideoInfo:(NSString *)url{ } } - MediaInfoDLL::MediaInfo MI = *new MediaInfoDLL::MediaInfo; - MI.Open([url cStringUsingEncoding:NSUTF8StringEncoding]); - MI.Option(__T("Inform"), __T("Video;%Width%")); - NSString *width = [NSString stringWithCString:MI.Inform().c_str() encoding:NSUTF8StringEncoding]; - MI.Option(__T("Inform"), __T("Video;%Height%")); - NSString *height = [NSString stringWithCString:MI.Inform().c_str() encoding:NSUTF8StringEncoding]; + MediaInfoDLL::MediaInfo *MI = new MediaInfoDLL::MediaInfo; + MI->Open([url cStringUsingEncoding:NSUTF8StringEncoding]); + MI->Option(__T("Inform"), __T("Video;%Width%")); + NSString *width = [NSString stringWithCString:MI->Inform().c_str() encoding:NSUTF8StringEncoding]; + MI->Option(__T("Inform"), __T("Video;%Height%")); + NSString *height = [NSString stringWithCString:MI->Inform().c_str() encoding:NSUTF8StringEncoding]; NSDictionary *info = @{ @"width": width, @"height": height, }; - delete &MI; + delete MI; return info; }