[trunk] fixed PDF crash in Chrome (fixes issue 362)
[trunk] added box length inconsistency check

Update issue 364

issue364-38.patch applied. Thanks Matthieu.
[trunk] fixed potential negative size params (fixes issue 390)