File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -1131,7 +1131,14 @@ static PyObject *
11311131mmap_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
You can’t perform that action at this time.
0 commit comments