Fix potential crash due to incorrectly handled content length