From e19e0c21aeeaf2aca6b044dd57070880ee76b9f5 Mon Sep 17 00:00:00 2001 From: Matthias Klose Date: Tue, 3 Apr 2007 04:35:59 +0000 Subject: [PATCH] - Fix an off-by-one bug in locale.strxfrm(). patch taken from http://bugs.debian.org/416934. --- Misc/NEWS | 3 +++ Modules/_localemodule.c | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Misc/NEWS b/Misc/NEWS index 9da3d3bc2ff..8ef7acb639f 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -681,6 +681,9 @@ Extension Modules - Bug #1633621: if curses.resizeterm() or curses.resize_term() is called, update _curses.LINES, _curses.COLS, curses.LINES and curses.COLS. +- Fix an off-by-one bug in locale.strxfrm(). + + Tests ----- diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c index abfca4eb163..02e9e53b274 100644 --- a/Modules/_localemodule.c +++ b/Modules/_localemodule.c @@ -360,7 +360,7 @@ PyLocale_strxfrm(PyObject* self, PyObject* args) buf = PyMem_Malloc(n1); if (!buf) return PyErr_NoMemory(); - n2 = strxfrm(buf, s, n1); + n2 = strxfrm(buf, s, n1) + 1; if (n2 > n1) { /* more space needed */ buf = PyMem_Realloc(buf, n2);