Skip to content

Commit

Permalink
Fix argument pointer may be null
Browse files Browse the repository at this point in the history
  • Loading branch information
cjee21 committed Jan 31, 2025
1 parent 9b2506d commit e6446c7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
6 changes: 4 additions & 2 deletions Source/MediaInfo/Audio/File_Ac4.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,12 @@ private :
uint8_t* Data_ToDelete=Data;
Size=NewOffset;
Data=new int8u[Size];
memcpy(Data, Data_ToDelete, Offset);
if (Data_ToDelete)
memcpy(Data, Data_ToDelete, Offset);
delete[] Data_ToDelete;
}
memcpy(Data+Offset, BufferToAdd, SizeToAdd);
if (Data+Offset)
memcpy(Data+Offset, BufferToAdd, SizeToAdd);
Offset=NewOffset;
}

Expand Down
5 changes: 4 additions & 1 deletion Source/MediaInfo/Audio/File_Adm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2141,7 +2141,10 @@ size_t Atmos_zone_Pos(const string& Name, float32* Values) {
}

string CraftName(const char* Name, bool ID = false) {
return (ID && !strcmp(Name, "Track")) ? "track" : ((Name && Name[0] < 'a' ? "audio" : "") + string(Name));
if (Name)
return (ID && !strcmp(Name, "Track")) ? "track" : ((Name && Name[0] < 'a' ? "audio" : "") + string(Name));
else
return "";
}

enum class E {
Expand Down
20 changes: 10 additions & 10 deletions Source/MediaInfo/ExternalCommandHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ int External_Command_Run(const Ztring& Command, const ZtringList& Arguments, Ztr
{
if (!CreatePipe(&StdErrRead, &StdErrWrite, &Attrs, 0))
{
CloseHandle(StdOutWrite);
CloseHandle(StdOutRead);
if (StdOutWrite) CloseHandle(StdOutWrite);
if (StdOutRead) CloseHandle(StdOutRead);
return -1;
}
}
Expand All @@ -182,15 +182,15 @@ int External_Command_Run(const Ztring& Command, const ZtringList& Arguments, Ztr

if (!CreateProcessW(nullptr, (LPWSTR)CommandLine.Read().To_Unicode().c_str(), nullptr, nullptr, TRUE, CREATE_NO_WINDOW, nullptr, nullptr, &StartupInfo, &ProcessInfo))
{
CloseHandle(StdOutWrite);
CloseHandle(StdOutRead);
CloseHandle(StdErrWrite);
CloseHandle(StdErrRead);
if (StdOutWrite) CloseHandle(StdOutWrite);
if (StdOutRead) CloseHandle(StdOutRead);
if (StdErrWrite) CloseHandle(StdErrWrite);
if (StdErrRead) CloseHandle(StdErrRead);
return -1;
}

CloseHandle(StdOutWrite);
CloseHandle(StdErrWrite);
if (StdOutWrite) CloseHandle(StdOutWrite);
if (StdErrWrite) CloseHandle(StdErrWrite);

char Buf[128];
if (StdOut)
Expand All @@ -214,8 +214,8 @@ int External_Command_Run(const Ztring& Command, const ZtringList& Arguments, Ztr
}
}

CloseHandle(StdOutRead);
CloseHandle(StdErrRead);
if (StdOutRead) CloseHandle(StdOutRead);
if (StdErrRead) CloseHandle(StdErrRead);

WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
GetExitCodeProcess(ProcessInfo.hProcess, &ExitCode);
Expand Down

0 comments on commit e6446c7

Please sign in to comment.