diff --git a/libcelt/pitch.c b/libcelt/pitch.c
index 4b38990a462858395213b2394f704d474a70d21d..abbe20329b8a10fa9714e13b72ea14c3d37e8bde 100644
--- a/libcelt/pitch.c
+++ b/libcelt/pitch.c
@@ -254,6 +254,8 @@ float remove_doubling(celt_word32 *pre[2], int COMBFILTER_MAXPERIOD, int N, int
          T = T1;
       }
    }
+   if (pg > g)
+      pg = g;
    /*printf ("%d %f\n", T, g);*/
    *_T0 = T;
    return pg;