r14023: My last bug fix still left a potential null deref.
authorJeremy Allison <jra@samba.org>
Wed, 8 Mar 2006 06:42:39 +0000 (06:42 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:11:06 +0000 (11:11 -0500)
C- "must try harder" :-).
Jeremy.
(This used to be commit 9c55bf74ca28530045c5cb3cbfffad242039ca75)

source3/printing/print_generic.c

index cb1c951ff74942efcf7ef8f3ae59414601438ab1..e445bc3ce0077eb595ce065d3fdb11eefa864bca 100644 (file)
@@ -200,16 +200,17 @@ static int generic_queue_get(const char *printer_name,
                        *q = NULL;
                        return 0;
                }
+               memset(queue, '\0', sizeof(print_queue_struct)*(numlines+1));
+
+               for (i=0; i<numlines; i++) {
+                       /* parse the line */
+                       if (parse_lpq_entry(printing_type,qlines[i],
+                                           &queue[qcount],status,qcount==0)) {
+                               qcount++;
+                       }
+               }               
        }
 
-       memset(queue, '\0', sizeof(print_queue_struct)*(numlines+1));
-       for (i=0; i<numlines; i++) {
-               /* parse the line */
-               if (parse_lpq_entry(printing_type,qlines[i],
-                                   &queue[qcount],status,qcount==0)) {
-                       qcount++;
-               }
-       }               
        file_lines_free(qlines);
         *q = queue;
        return qcount;