diff --git a/modules/libpr0n/src/imgContainer.cpp b/modules/libpr0n/src/imgContainer.cpp index ee261defaf3..776c4ee6920 100644 --- a/modules/libpr0n/src/imgContainer.cpp +++ b/modules/libpr0n/src/imgContainer.cpp @@ -157,12 +157,17 @@ NS_IMETHODIMP imgContainer::GetNumFrames(PRUint32 *aNumFrames) /* gfxIImageFrame getFrameAt (in unsigned long index); */ NS_IMETHODIMP imgContainer::GetFrameAt(PRUint32 index, gfxIImageFrame **_retval) { - NS_ENSURE_ARG(index < static_cast(mFrames.Count())); - NS_ASSERTION(_retval, "imgContainer::GetFrameAt; Invalid Arg"); if (!_retval) return NS_ERROR_INVALID_POINTER; + if (!mFrames.Count()) { + *_retval = nsnull; + return NS_OK; + } + + NS_ENSURE_ARG(index < static_cast(mFrames.Count())); + if (!(*_retval = mFrames[index])) return NS_ERROR_FAILURE;