]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Fix memory leaks.
authorMichael Sweet <michael.r.sweet@gmail.com>
Thu, 14 Sep 2017 18:12:49 +0000 (14:12 -0400)
committerMichael Sweet <michael.r.sweet@gmail.com>
Thu, 14 Sep 2017 18:12:49 +0000 (14:12 -0400)
cups/file.c
cups/ipp.c
cups/thread-private.h
cups/thread.c
cups/usersys.c
test/ipptool.c

index 8cdf0368ce5ae422b4696455eac32895b9caf779..5d1505403884e431ab406670928423a6744ca3c6 100644 (file)
@@ -2477,6 +2477,8 @@ cups_fill(cups_file_t *fp)                /* I - CUPS file */
        * file header...
        */
 
+        inflateEnd(&fp->stream);
+
        fp->compressed = 0;
       }
       else if (status < Z_OK)
index 5fd58704086c3c63099b1b56b66414d8d91ec704..d974bbab8278bba8ff771b260f6507d8ab0603f4 100644 (file)
@@ -1838,12 +1838,19 @@ ippDelete(ipp_t *ipp)                   /* I - IPP message */
 
   ipp->use --;
   if (ipp->use > 0)
+  {
+    DEBUG_printf(("4debug_retain: %p IPP message (use=%d)", (void *)ipp, ipp->use));
     return;
+  }
+
+  DEBUG_printf(("4debug_free: %p IPP message", (void *)ipp));
 
   for (attr = ipp->attrs; attr != NULL; attr = next)
   {
     next = attr->next;
 
+    DEBUG_printf(("4debug_free: %p %s %s%s (%d values)", (void *)attr, attr->name, attr->num_values > 1 ? "1setOf " : "", ippTagString(attr->value_tag), attr->num_values));
+
     ipp_free_values(attr, 0, attr->num_values);
 
     if (attr->name)
@@ -1880,6 +1887,8 @@ ippDeleteAttribute(
   if (!attr)
     return;
 
+  DEBUG_printf(("4debug_free: %p %s %s%s (%d values)", (void *)attr, attr->name, attr->num_values > 1 ? "1setOf " : "", ippTagString(attr->value_tag), attr->num_values));
+
  /*
   * Find the attribute in the list...
   */
@@ -2715,6 +2724,8 @@ ippNew(void)
     * Set default version - usually 2.0...
     */
 
+    DEBUG_printf(("4debug_alloc: %p IPP message", (void *)temp));
+
     if (cg->server_version == 0)
       _cupsSetDefaults();
 
@@ -6412,6 +6423,8 @@ ipp_add_attr(ipp_t      *ipp,             /* I - IPP message */
     * Initialize attribute...
     */
 
+    DEBUG_printf(("4debug_alloc: %p %s %s%s (%d values)", (void *)attr, name, num_values > 1 ? "1setOf " : "", ippTagString(value_tag), num_values));
+
     if (name)
       attr->name = _cupsStrAlloc(name);
 
@@ -6968,6 +6981,9 @@ ipp_set_value(ipp_t           *ipp,       /* IO - IPP message */
     * Reset pointers in the list...
     */
 
+    DEBUG_printf(("4debug_free: %p %s %s%s (%d)", (void *)*attr, (*attr)->name, (*attr)->num_values > 1 ? "1setOf " : "", ippTagString((*attr)->value_tag), (*attr)->num_values));
+    DEBUG_printf(("4debug_alloc: %p %s %s%s (%d)", (void *)temp, temp->name, temp->num_values > 1 ? "1setOf " : "", ippTagString(temp->value_tag), temp->num_values));
+
     if (ipp->current == *attr && ipp->prev)
     {
      /*
index ca4ef4cb4bf9e23b806322cad253208c9a657855..79d2438679939b3352a186384d4fb44ef52cbbd4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Private threading definitions for CUPS.
  *
- * Copyright 2009-2016 by Apple Inc.
+ * Copyright 2009-2017 by Apple Inc.
  *
  * These coded instructions, statements, and computer programs are the
  * property of Apple Inc. and are protected by Federal copyright
@@ -99,6 +99,7 @@ extern void   _cupsRWLockWrite(_cups_rwlock_t *rwlock);
 extern void    _cupsRWUnlock(_cups_rwlock_t *rwlock);
 extern void    _cupsThreadCancel(_cups_thread_t thread);
 extern _cups_thread_t _cupsThreadCreate(_cups_thread_func_t func, void *arg);
+extern void     _cupsThreadDetach(_cups_thread_t thread);
 extern void    *_cupsThreadWait(_cups_thread_t thread);
 
 #  ifdef __cplusplus
index 77b44426e49156d72c96e03898733b051cf9a26c..7af45ea70c9fb4d680d14072be5c3d027a3452c4 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Threading primitives for CUPS.
  *
- * Copyright 2009-2016 by Apple Inc.
+ * Copyright 2009-2017 by Apple Inc.
  *
  * These coded instructions, statements, and computer programs are the
  * property of Apple Inc. and are protected by Federal copyright
@@ -172,6 +172,17 @@ _cupsThreadCreate(
 }
 
 
+/*
+ * '_cupsThreadDetach()' - Tell the OS that the thread is running independently.
+ */
+
+void
+_cupsThreadDetach(_cups_thread_t thread)/* I - Thread ID */
+{
+  pthread_detach(thread);
+}
+
+
 /*
  * '_cupsThreadWait()' - Wait for a thread to exit.
  */
index ff5cb30837d1edcd2b05871b48d6c363777b6c1c..026b4a7cc493760193de0b93d989b4784b6066f8 100644 (file)
@@ -1175,7 +1175,7 @@ cups_init_client_conf(
   * everything...)
   */
 
-#ifdef __APPLE__
+#if defined(__APPLE__) && defined(HAVE_SSL)
   char sval[1024];                     /* String value */
   int  bval;                           /* Boolean value */
 
@@ -1196,7 +1196,7 @@ cups_init_client_conf(
 
   if (cups_apple_get_boolean(kValidateCertsKey, &bval))
     cc->validate_certs = bval;
-#endif /* __APPLE__ */
+#endif /* __APPLE__ && HAVE_SSL */
 }
 
 
index 40a71b772f70a6212f04bb7b484cd5d66e77fc81..658927ae08efa28f347333788c34063c31969e4b 100644 (file)
@@ -3323,8 +3323,7 @@ do_tests(cups_file_t  *outfile,           /* I - Output file */
       }
 
      /*
-      * If we are going to repeat this test, sleep 1 second so we don't flood
-      * the printer with requests...
+      * If we are going to repeat this test, display intermediate results...
       */
 
       if (repeat_test)
@@ -3357,6 +3356,9 @@ do_tests(cups_file_t  *outfile,           /* I - Output file */
        {
          cupsFilePrintf(cupsFileStdout(), "    %-68.68s [", name);
        }
+
+        ippDelete(response);
+        response = NULL;
       }
     }
     while (repeat_test);