Re: [PATCH 1/3] perf script python: Fix string vs byte array resolving

From: Steven Rostedt
Date: Fri Jul 15 2016 - 13:18:49 EST


On Fri, 15 Jul 2016 09:29:55 +0200
Jiri Olsa <jolsa@xxxxxxxxxx> wrote:

> + if (field->flags & FIELD_IS_STRING &&
> + is_printable_array(data + offset, len)) {
> + obj = PyString_FromString((char *) data + offset);

Hmm. As I stated, It is possible that strings can be non nul
terminated. But I'm looking here and thinking we need to make sure that
it is nul terminated.

Can PyString_FromString() handle a non nul terminated string?

-- Steve

> + } else {
> + obj = PyByteArray_FromStringAndSize((const char *) data + offset, len);
> + field->flags &= ~FIELD_IS_STRING;
> + }
> } else { /* FIELD_IS_NUMERIC */
> obj = get_field_numeric_entry(event, field, data);
> }