Skip to content

Commit

Permalink
Fix Issue dib-lab#174 - ktable.get(wrong_length_string) gives core dump
Browse files Browse the repository at this point in the history
  • Loading branch information
Echelon9 committed Aug 30, 2014
1 parent 3274692 commit eb4a04c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions khmer/_khmermodule.cc
Original file line number Diff line number Diff line change
@@ -1367,6 +1367,13 @@ static PyObject * hash_get(PyObject * self, PyObject * args)
count = counting->get_count((unsigned int) pos);
} else if (PyString_Check(arg)) {
std::string s = PyString_AsString(arg);

if (strlen(s.c_str()) < counting->ksize()) {
PyErr_SetString(PyExc_ValueError,
"string length must >= the hashtable k-mer size");
return NULL;
}

count = counting->get_count(s.c_str());
}

@@ -2328,6 +2335,13 @@ static PyObject * hashbits_get(PyObject * self, PyObject * args)
count = hashbits->get_count((unsigned int) pos);
} else if (PyString_Check(arg)) {
std::string s = PyString_AsString(arg);

if (strlen(s.c_str()) < hashbits->ksize()) {
PyErr_SetString(PyExc_ValueError,
"string length must >= the hashtable k-mer size");
return NULL;
}

count = hashbits->get_count(s.c_str());
} else {
PyErr_SetString(PyExc_ValueError, "must pass in an int or string");

0 comments on commit eb4a04c

Please sign in to comment.