Forum > Packages and Libraries

fpExif - range check error

(1/2) > >>

Mirkasp:
Hi wp!
The fpExif package is super, but in my application, in same jpg files I have run-time error: "Range check error" in file fpeutils.pas at line 1370.
Maybe the following code would be more appropriate:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function PosInBytes( const AText: AnsiString; ABuffer: TBytes ): Integer;  var n: Integer;begin  n := Length( AText );  if (n > 0) and Assigned( ABuffer ) then begin    for Result := Low( ABuffer ) to High( ABuffer )-n+1 do      if {%H-}CompareMem( @ABuffer[ Result ], Pointer( AText), n ) then        exit;  end;  Result := -1;end; A sample jpg file is attached.

I have also a lot of unsupported exif tags in second attachment. Please check them and add them to fpeexifdata.pas

Sorry for my english :)
Best regards
MirKasp

Awkward:
looks like you comparing pointers as is but not content on their address

marcov:
if n=length(abuffer)=high(abuffer)+1


what is high(abuffer)-n+1  supposed to do? It always evaluates to zero.

High and low on dynamic arrays (as opposed to open arrays) are a bit shady anyway, and I don't know if that works. Iteration on dynamic arrays are 0..length(arr)-1.

wp:
Applied.


--- Quote from: marcov on July 28, 2022, 10:45:58 pm ---what is high(abuffer)-n+1  supposed to do? It always evaluates to zero.
--- End quote ---
No. n is the length of the string, not the length of buffer. The code makes sure that the last comparison run starts at such an index that the comparison with the text bytes just stays inside the buffer.


--- Quote from: Awkward on July 28, 2022, 09:55:02 pm ---looks like you comparing pointers as is but not content on their address

--- End quote ---
That's the way CompareMem is called, it has the pointers to the start of the memory blocks to be compared as parameters (https://www.freepascal.org/docs-html/rtl/sysutils/comparemem.html).


--- Quote from: Mirkasp on July 28, 2022, 09:09:56 pm ---I have also a lot of unsupported exif tags in second attachment. Please check them and add them to fpeexifdata.pas

--- End quote ---
Please provide images that show that these tags really exist (at least some of them). What your patch is doing is moving tags which should be in the Exif directory into the primary directory, for example.

Mirkasp:
Thank you, it works fine now.

--- Quote ---Please provide images that show that these tags really exist (at least some of them). What your patch is doing is moving tags which should be in the Exif directory into the primary directory, for example.
--- End quote ---
I wrote an application lxImgScanner http://mikron.epizy.com/strona-glowna/lximgscanner-2/ that uses fpExif and looks for unnamed tags in jpg files. Please check it.
An example with an unnamed tag attached.

Navigation

[0] Message Index

[#] Next page

Go to full version