Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fd0226b

Browse files
committed
Use c2pstr() in stead of Pstring() to convert C-strings to
Pascal-strings. Safer, because Pstring converts in-place and the pathname may be reused later for error messages.
1 parent 27489d4 commit fd0226b

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

Python/dynload_mac.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "TFileSpec.h" /* for Path2FSSpec() */
1111
#endif
1212
#include <Files.h>
13+
#include <TextUtils.h>
1314
#include "macdefs.h"
1415
#include "macglue.h"
1516

@@ -56,12 +57,12 @@ dl_funcptr _PyImport_GetDynLoadFunc(const char *fqname, const char *shortname,
5657
#ifdef USE_GUSI1
5758
err = Path2FSSpec(pathname, &libspec);
5859
#else
59-
(void)FSMakeFSSpec(0, 0, Pstring(pathname), &libspec);
60+
c2pstrcpy((unsigned char *)buf, pathname);
61+
(void)FSMakeFSSpec(0, 0, (unsigned char *)buf, &libspec);
6062
err = ResolveAliasFile(&libspec, 1, &isfolder, &didsomething);
6163
#endif
6264
if ( err ) {
63-
sprintf(buf, "%.255s: %.200s",
64-
pathname, PyMac_StrError(err));
65+
sprintf(buf, "%.200s: %.200s", pathname, PyMac_StrError(err));
6566
PyErr_SetString(PyExc_ImportError, buf);
6667
return NULL;
6768
}

0 commit comments

Comments
 (0)