• Welcome to Vampyre Imaging Library Forum. Please login or sign up.
 

Post reply

Other options

Shortcuts: ALT+S save/post or ALT+P preview

Topic summary

Posted by Galfar
 - 23 August 2018, 14:17:52
Thanks for the report, just pushed your fix to the repo.
Posted by Johannes
 -  7 February 2018, 02:42:04
I have looked into the code of ImagingOpenGL.pas and found something weird:

function CreateMultiImageFromGLTexture(const Texture: GLuint;
  var Images: TDynImageDataArray; MipLevels: LongInt; OverrideFormat: TImageFormat): Boolean;
var
  I, Width, Height, ExistingLevels: LongInt;
begin
  FreeImagesInArray(Images);
  SetLength(Images, 0);
  Result := False;
  if Byte(glIsTexture(Texture)) = GL_TRUE then
  begin
    // Check if desired mipmap level count is valid
    glBindTexture(GL_TEXTURE_2D, Texture);
    if MipLevels <= 0 then
      MipLevels := GetNumMipMapLevels(Width, Height);  //<- Here it tries to access uninitialized memory (Line 849)
    SetLength(Images, MipLevels);


A possible fix would be:
         
    if MipLevels <= 0 then
      begin
        glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, @Width);
        glGetTexLevelParameteriv(GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, @Height);
        MipLevels := GetNumMipMapLevels(Width, Height);
      end;

SMF spam blocked by CleanTalk