HemulGM / DelphiOpenAI

OpenAI API wrapper for Delphi. Use ChatGPT, DALL-E, Whisper and other products.
MIT License
242 stars 58 forks source link

TFileCreateParams missing constructor causing invalid access to internal stream #10

Closed wxinix-2022 closed 1 year ago

wxinix-2022 commented 1 year ago

https://github.com/HemulGM/DelphiOpenAI/blob/main/OpenAI.Files.pas

Line 18,

TFileCreateParams inherits from TMultipartFormData. However, TFileCreateParams didn't implement its own constructor. Therefore, TFileCreateParams.Create will call TObject.Create, skipping all the initialization code inside TMultipartFormData.Create(...).

This later will result invalid access to Stream object inside TMultipartFormData.

HemulGM commented 1 year ago

Yes, it looks like it. Didn't look that there is no standard constructor for TMultipartFormData

HemulGM commented 1 year ago

Fixed

wxinix-2022 commented 1 year ago

OpenAI.Images, TImageCreateParams, TImageVariationParams appear to have the same issue - missing constructors.

HemulGM commented 1 year ago

TImageCreateParams - the constructor of the parent is sufficient.

TImageVariationParams - has a constructor

wxinix-2022 commented 1 year ago

right. I meant TImageEditParams (not TImageCreateParams). I see they are already fixed.