Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix fuzz test case and python strlists #404

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/pdb/pdlow.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ _lite_PD_rd_chrt (PDBfile *file) {
*/
chrt_sz = file->symtaddr - file->chrtaddr + 1;
_lite_PD_tbuffer = MAKE_N(char, chrt_sz);
if (chrt_sz <= 0) return(FALSE);
if (io_read(_lite_PD_tbuffer, 1, chrt_sz, fp) != chrt_sz) return(FALSE);
_lite_PD_tbuffer[chrt_sz-1] = (char) EOF;

Expand Down
13 changes: 11 additions & 2 deletions tools/python/pydbfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ static PyObject *DBfile_DBGetToc(PyObject *self, PyObject *args)
// construct is used for *both* string valued members and variable
// members whose value is also a string but is the name of another dataset
// in the file.
//
// Mark C. Miller, Thu Aug 22 00:34:52 PDT 2024
// Skip possible empty first and last strings in a string list.
// ****************************************************************************
static PyObject *DBfile_DBGetVar(PyObject *self, PyObject *args)
{
Expand Down Expand Up @@ -199,13 +202,19 @@ static PyObject *DBfile_DBGetVar(PyObject *self, PyObject *args)
char **strArr = DBStringListToStringArray((char*)var, &narr, 0);
if (narr > 0 && strArr)
{
tmp = PyTuple_New(narr);
PyObject *tmp2 = PyList_New(0);
for (int i = 0; i < narr; i++)
{
PyTuple_SET_ITEM(tmp, i, PyString_FromString(strArr[i]));
if (i == 0 && strArr[i] && strArr[i][0] == '\0')
continue; // skip an empty first entry
if (i == (narr-1) && strArr[i] && strArr[i][0] == '\0')
continue; // skip an empty last entry
PyList_Append(tmp2, PyString_FromString(strArr[i]));
FREE(strArr[i]);
}
FREE(strArr);
tmp = PyList_AsTuple(tmp2);
Py_DECREF(tmp2);
}
else
{
Expand Down