integer overflow in TWPOImage.WriteRTFData with BMP images

  • Hi,

    I use Delphi 2009 and WPTools 6.03.5.

    I get an integer overflow when I try to save my document to the database (as a stream).

    Seems to happen only when I include BMP images in my document using the Insert / Graphic menu (everything works fine with JPG images).

    Note that the problem arose after we moved from D2006 / WPTools 5.47 and that everything worked fine with the very same documents before.


    Exception occurs in :

    TWPOImage.WriteRTFData :

    at last instruction of block :

    else if Picture.Graphic is TBitmap then
    try
    bin := TMemoryStream.Create;
    Picture.Bitmap.SaveToStream(bin);
    if bin.Size > 0 then
    begin
    InfoHeader := Pointer(Pchar(bin.Memory) + SizeOf(TBitmapFileHeader));
    { l := bin.Size; }
    //h := MulDiv(Picture.Graphic.Height, 1440, 96);
    //w := MulDiv(Picture.Graphic.Width, 1440, 96);
    StrPLCopy(buf, '\dibitmap0'
    + '\wbmbitspixel' + IntToStr(InfoHeader^.biBitCount)
    + '\wbmplanes' + IntToStr(InfoHeader^.biPlanes)
    + '\wbmwidthbytes' + IntToStr((InfoHeader^.biWidth
    * InfoHeader^.biBitCount + 7) div 8)
    + '\picw' + IntToStr(InfoHeader^.biWidth)
    + '\pich' + IntToStr(InfoHeader^.biHeight)
    // + '\picscalex' + IntToStr(muldiv(AliasTextObj.Width, 100, w))
    // + '\picscaley' + IntToStr(muldiv(AliasTextObj.Height, 100, h))
    + '\picwgoal' + IntToStr(AliasTextObj.Width)
    + '\pichgoal' + IntToStr(AliasTextObj.Height) + #13#10, 400);


    Thanks,
    Attila

    • Offizieller Beitrag

    Hi,

    seems to me anothe problem introduced by Delphi 2009:

    InfoHeader := Pointer(Pchar(bin.Memory) + SizeOf(TBitmapFileHeader));


    This should read

    InfoHeader := Pointer(PAnsichar(bin.Memory) + SizeOf(TBitmapFileHeader));

    Julian