diff --git a/libcelt/celt.c b/libcelt/celt.c
index f0a25e7f28715627c9d8473cd138caf0c31e1785..9d812ed27f653342ca297a9f5a83a23a4b1f2eef 100644
--- a/libcelt/celt.c
+++ b/libcelt/celt.c
@@ -919,7 +919,7 @@ int celt_encode_with_ec_float(CELTEncoder * restrict st, const celt_sig * pcm, i
    int silence=0;
    SAVE_STACK;
 
-   if (nbCompressedBytes<2 || pcm==NULL)
+   if (nbCompressedBytes<2 || nbCompressedBytes>1275 || pcm==NULL)
      return CELT_BAD_ARG;
 
    frame_size *= st->upsample;
@@ -2180,7 +2180,7 @@ int celt_decode_with_ec_float(CELTDecoder * restrict st, const unsigned char *da
 
    SAVE_STACK;
 
-   if (pcm==NULL)
+   if (len<0 || len>1275 || pcm==NULL)
       return CELT_BAD_ARG;
 
    frame_size *= st->downsample;