From 68a71bf1ac4359e584ac36cc33e2d37d323563a6 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Mon, 9 May 2016 14:28:51 +0200 Subject: Validate explosions length --- src/ch/epfl/xblast/client/GameStateDeserializer.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ch/epfl/xblast/client/GameStateDeserializer.java b/src/ch/epfl/xblast/client/GameStateDeserializer.java index e2039ed..8b203b1 100644 --- a/src/ch/epfl/xblast/client/GameStateDeserializer.java +++ b/src/ch/epfl/xblast/client/GameStateDeserializer.java @@ -141,9 +141,15 @@ public final class GameStateDeserializer { * * @param serializedExplosions the run-length-compressed, serialized explosions * @return the explosions + * @throws IllegalArgumentException if the length of the serialized explosions is invalid */ private static List deserializeExplosions(List serializedExplosions) { - return deserializeImageChunk(serializedExplosions, ImageCollection.EXPLOSIONS_IMAGES); + List explosions = deserializeImageChunk(serializedExplosions, ImageCollection.EXPLOSIONS_IMAGES); + + if (explosions.size() != Cell.ROW_MAJOR_ORDER.size()) + throw new IllegalArgumentException(); + + return explosions; } /** -- cgit v1.2.3