[New-bugs-announce] [issue22330] PyOS_mystricmp is broken

Masahiro Konishi report at bugs.python.org
Wed Sep 3 11:04:29 CEST 2014

New submission from Masahiro Konishi:

int x = PyOS_mystricmp("foo", "none");
expected: x < 0
actual:   x == 0

    while (*s1 && (tolower((unsigned)*s1++) == tolower((unsigned)*s2++))) {
    return (tolower((unsigned)*s1) - tolower((unsigned)*s2));

The while-loop is finished when *s1 != *s2 (ex. *s1 == 'f', *s2 == 'n'), but s1 and s2 already point to next characters (ex. *s1 == 'o', *s2 == 'o'), so PyOS_mystricmp returns difference between these characters.

components: Interpreter Core
files: pystrcmp.c.patch
keywords: patch
messages: 226303
nosy: kakkoko
priority: normal
severity: normal
status: open
title: PyOS_mystricmp is broken
type: behavior
versions: Python 3.4
Added file: http://bugs.python.org/file36529/pystrcmp.c.patch

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list