Staging
v0.5.1
https://github.com/python/cpython
Revision b14a68fd7d8f02bd133b59709f969c1c564f5978 authored by Miss Islington (bot) on 22 August 2018, 05:54:39 UTC, committed by GitHub on 22 August 2018, 05:54:39 UTC

Reported by Svace static analyzer.
(cherry picked from commit f8c06b028036e50596e75d4c9f6b27ba05133efe)

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
1 parent e496b2b
Raw File
Tip revision: b14a68fd7d8f02bd133b59709f969c1c564f5978 authored by Miss Islington (bot) on 22 August 2018, 05:54:39 UTC
bpo-34456: pickle: Add missing NULL check to save_global(). (GH-8851)
Tip revision: b14a68f
pystrcmp.c
/* Cross platform case insensitive string compare functions
 */

#include "Python.h"

int
PyOS_mystrnicmp(const char *s1, const char *s2, Py_ssize_t size)
{
    if (size == 0)
        return 0;
    while ((--size > 0) &&
           (tolower((unsigned)*s1) == tolower((unsigned)*s2))) {
        if (!*s1++ || !*s2++)
            break;
    }
    return tolower((unsigned)*s1) - tolower((unsigned)*s2);
}

int
PyOS_mystricmp(const char *s1, const char *s2)
{
    while (*s1 && (tolower((unsigned)*s1++) == tolower((unsigned)*s2++))) {
        ;
    }
    return (tolower((unsigned)*s1) - tolower((unsigned)*s2));
}
back to top