Ticket #495: crash_precond.diff

File crash_precond.diff, 2.7 KB (added by greg, at 2008-07-25T16:32:18Z)

fix crash and precondition exception

  • zfec\_fecmodule.c

    old new  
    6262        return -1;
    6363
    6464    if (ink < 1) {
    65         PyErr_Format(py_fec_error, "Precondition violation: first argument is required to be greater than or equal to 1, but it was %d", self->kk);
     65        PyErr_Format(py_fec_error, "Precondition violation: first argument is required to be greater than or equal to 1, but it was %d", ink);
    6666        return -1;
    6767    }
    6868    if (inm < 1) {
    69         PyErr_Format(py_fec_error, "Precondition violation: second argument is required to be greater than or equal to 1, but it was %d", self->mm);
     69        PyErr_Format(py_fec_error, "Precondition violation: second argument is required to be greater than or equal to 1, but it was %d", inm);
    7070        return -1;
    7171    }
    7272    if (inm > 256) {
    73         PyErr_Format(py_fec_error, "Precondition violation: second argument is required to be less than or equal to 256, but it was %d", self->mm);
     73        PyErr_Format(py_fec_error, "Precondition violation: second argument is required to be less than or equal to 256, but it was %d", inm);
    7474        return -1;
    7575    }
    7676    if (ink > inm) {
     
    220220
    221221static void
    222222Encoder_dealloc(Encoder * self) {
    223     fec_free(self->fec_matrix);
     223    if (self->fec_matrix)
     224        fec_free(self->fec_matrix);
    224225    self->ob_type->tp_free((PyObject*)self);
    225226}
    226227
     
    321322        return -1;
    322323
    323324    if (ink < 1) {
    324         PyErr_Format(py_fec_error, "Precondition violation: first argument is required to be greater than or equal to 1, but it was %d", self->kk);
     325        PyErr_Format(py_fec_error, "Precondition violation: first argument is required to be greater than or equal to 1, but it was %d", ink);
    325326        return -1;
    326327    }
    327328    if (inm < 1) {
    328         PyErr_Format(py_fec_error, "Precondition violation: second argument is required to be greater than or equal to 1, but it was %d", self->mm);
     329        PyErr_Format(py_fec_error, "Precondition violation: second argument is required to be greater than or equal to 1, but it was %d", inm);
    329330        return -1;
    330331    }
    331332    if (inm > 256) {
    332         PyErr_Format(py_fec_error, "Precondition violation: second argument is required to be less than or equal to 256, but it was %d", self->mm);
     333        PyErr_Format(py_fec_error, "Precondition violation: second argument is required to be less than or equal to 256, but it was %d", inm);
    333334        return -1;
    334335    }
    335336    if (ink > inm) {
     
    492493
    493494static void
    494495Decoder_dealloc(Decoder * self) {
    495     fec_free(self->fec_matrix);
     496    if (self->fec_matrix)
     497        fec_free(self->fec_matrix);
    496498    self->ob_type->tp_free((PyObject*)self);
    497499}
    498500