dspack-continued-mirror-for-delphinus icon indicating copy to clipboard operation
dspack-continued-mirror-for-delphinus copied to clipboard

Async Source filter demo: AV in Grapgstudionext when trying to view Pin properties for disconnected filter

Open Ayuus opened this issue 2 years ago • 0 comments

In file https://github.com/micha137/dspack-continued-mirror-for-delphinus/blob/master/Demos/D6-D7/Filters/Async/UAsyncRdr.pas, function TBCAsyncOutputPin.GetMediaType results in an AV in Graphstudionext.

REproduction: build an register filter, load filter in Graphstudionext, right-click the output pin an select Properties. Application crashes as an AV has occured.

I think error is in function below, where parameter MediaType may not be initialized (nil). In that case, CopyMEmory results in an AV. I suggest modification as below: "if not Assigned(MediaType)...".

What do you think?

function TBCAsyncOutputPin.GetMediaType(Position: Integer;
  out MediaType: PAMMediaType): HResult;
begin
  if (Position < 0) then
    Result := E_INVALIDARG
  else
    if (Position > 0) then
      Result := VFW_S_NO_MORE_ITEMS
    else
      begin
        if (FReader = nil) then
        begin
          Result := E_UNEXPECTED;
          Exit;
        end;

    if not Assigned(MediaType) then
    begin
      MediaType := CoTaskMemAlloc(SizeOf(TAMMediaType));
    end;

        CopyMemory(MediaType, FReader.LoadType, SizeOf(TAMMediaType));
        Result := S_OK;
      end;
end;

Ayuus avatar Jul 04 '22 09:07 Ayuus