Skip to content

Commit d354eba

Browse files
committed
nit
1 parent c65e691 commit d354eba

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Modules/mmapmodule.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1131,7 +1131,14 @@ static PyObject *
11311131
mmap_mmap_set_name_impl(mmap_object *self, const char *name)
11321132
/*[clinic end generated code: output=1edaf4fd51277760 input=6c7dd91cad205f07]*/
11331133
{
1134-
_PyAnnotateMemoryMap(self->data, self->size, name);
1134+
char buf[80] = {0, };
1135+
const char* prefix = "cpython:mmap:";
1136+
if (strlen(name) + strlen(prefix) > 80) {
1137+
PyErr_SetString(PyExc_ValueError, "name too long");
1138+
return NULL;
1139+
}
1140+
sprintf(buf, "%s%s", prefix, name);
1141+
_PyAnnotateMemoryMap(self->data, self->size, buf);
11351142
Py_RETURN_NONE;
11361143
}
11371144

@@ -1415,6 +1422,7 @@ static struct PyMethodDef mmap_object_methods[] = {
14151422
MMAP_MMAP_RESIZE_METHODDEF
14161423
MMAP_MMAP_SEEK_METHODDEF
14171424
MMAP_MMAP_SEEKABLE_METHODDEF
1425+
MMAP_MMAP_SET_NAME_METHODDEF
14181426
MMAP_MMAP_SIZE_METHODDEF
14191427
MMAP_MMAP_TELL_METHODDEF
14201428
MMAP_MMAP_WRITE_METHODDEF

0 commit comments

Comments
 (0)