]> granicus.if.org Git - python/commitdiff
Use correct function name to PyArg_ParseTuple("is_package").
authorNeal Norwitz <nnorwitz@gmail.com>
Mon, 17 Feb 2003 18:05:20 +0000 (18:05 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Mon, 17 Feb 2003 18:05:20 +0000 (18:05 +0000)
Fix off-by-1 error in normalize_line_endings():
  when *p == '\0' the NUL was copied into q and q was auto-incremented,
  the loop was broken out of,
  then a newline was appended followed by a NUL.
  So the function, in effect, was strcpy() but added two extra chars
  which was caught by obmalloc in debug mode, since there was only
  room for 1 additional newline.

Get test working under regrtest (added test_main).

Lib/test/test_zipimport.py
Modules/zipimport.c

index 3c9457f765fd3724e34fcf82068f726287f66100..c9aff4ac1d6eedb7b2994f73bdd36347f6ad8221 100644 (file)
@@ -186,6 +186,9 @@ class CompressedZipImportTestCase(UncompressedZipImportTestCase):
     compression = ZIP_DEFLATED
 
 
-if __name__ == "__main__":
+def test_main():
     test_support.run_unittest(UncompressedZipImportTestCase)
     test_support.run_unittest(CompressedZipImportTestCase)
+
+if __name__ == "__main__":
+    test_main()
index 159a6b089522cec40608dcae2ffef15e1421087c..4c796f3cd2d7fbd688d53ab560cd8adc69ace55e 100644 (file)
@@ -371,7 +371,7 @@ zipimporter_is_package(PyObject *obj, PyObject *args)
        char *fullname;
        enum module_info mi;
 
-       if (!PyArg_ParseTuple(args, "s:zipimporter.find_module",
+       if (!PyArg_ParseTuple(args, "s:zipimporter.is_package",
                              &fullname))
                return NULL;
 
@@ -947,7 +947,7 @@ normalize_line_endings(PyObject *source)
                return NULL;
        }
        /* replace "\r\n?" by "\n" */
-       for (q = buf;;) {
+       for (q = buf; *p != '\0'; p++) {
                if (*p == '\r') {
                        *q++ = '\n';
                        if (*(p + 1) == '\n')
@@ -955,9 +955,6 @@ normalize_line_endings(PyObject *source)
                }
                else
                        *q++ = *p;
-               if (*p == '\0')
-                       break;
-               p++;
        }
        *q++ = '\n';  /* add trailing \n */
        *q = '\0';