try catch block for the unpack function
<p>Our apache error_log was recently filled up with lines similar to the following (about 50GB):</p>

<pre><code>[Wed Feb 01 16:50:15 2012] [error] [client 123.123.123.123] PHP Warning:
unpack() [&lt;a href='function.unpack'&gt;function.unpack&lt;/a&gt;]:  
 Type V: not enough input,  need 4, have 1
    in /var/www/vhosts/domain.com/httpdocs/imagecreatefrombmp.php on line 52
</code></pre>

<p>Line 52 in imagecreatefrombmp.bmp is as follows:  </p>

<pre><code>$COLOR = unpack("V",substr($IMG,$P,3).$VIDE);
</code></pre>

<p>This line is buried in a while loop.</p>

<p>If this issue happens again I want the code to quietly exit the while loop.</p>

<p>The problem is I cannot replicate the problem myself so I sort of need to solve it blind.</p>

<p>I've devised the following little solution. Would it serve the purpose? If the "Type V not input..." error occurs again would the try catch block catch it and return false?</p>

<pre><code>    try{
        $COLOR = unpack("V",substr($IMG,$P,3).$VIDE);            
    }catch (Exception $e) {
        return FALSE;        
    }
</code></pre>
