JamesHeinrich / getID3

http://www.getid3.org/
Other
1.13k stars 245 forks source link

fread(): Argument #2 ($length) must be greater than 0 #426

Closed siva-cometchat closed 8 months ago

siva-cometchat commented 8 months ago

I am encountering this error: fread(): Argument #2 ($length) must be greater than 0 File: module.tag.xmp Line no: 148 - $segdata = fread($filehnd, $decodedsize['size'] - 2);

The value of $decodedsize['size'] is 2, it seems that the segment is very small, likely containing only a marker and no additional data. fread is trying to read 2 bytes (the segment size) from the file, but $decodedsize['size'] - 2 evaluates to 0. It means that the segment size is indeed 2, and there is no additional data to read, which is why fread is producing this error.

To handle this situation, you can add a conditional check to ensure that you only attempt to read data when the segment size is greater than 2:

if ($decodedsize['size'] > 2) {
    $segdata = fread($filehnd, $decodedsize['size'] - 2);
} else {
    // Handle the case when there is no data to read.
    $segdata = ''; // Or any other appropriate action
}
JamesHeinrich commented 8 months ago

Looks like a duplicate of what was already fixed in https://github.com/JamesHeinrich/getID3/issues/418