r14003: Clarify code that lead to Coverity report #13.
authorJeremy Allison <jra@samba.org>
Wed, 8 Mar 2006 01:18:18 +0000 (01:18 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 16:11:04 +0000 (11:11 -0500)
Not a bug, but better to remove false positives.
Jeremy.
(This used to be commit f9a75d76546bc4618736f0d48646e77d7572db25)

source3/printing/lpq_parse.c
source3/printing/print_generic.c

index 68c06ade41f0240df99dbb055d992d9182f5539b..7e81b5187c9cef1579a24c8e848db7f3cf944ebd 100644 (file)
@@ -971,7 +971,7 @@ BOOL parse_lpq_entry(enum printing_types printing_type,char *line,
   }
 
   /* in the LPRNG case, we skip lines starting by a space.*/
-  if (line && !ret && (printing_type==PRINT_LPRNG) )
+  if (!ret && (printing_type==PRINT_LPRNG) )
   {
        if (line[0]==' ')
                return ret;
index 18fca67860098be0c5c4285dd0657406e40fb6f3..cb1c951ff74942efcf7ef8f3ae59414601438ab1 100644 (file)
@@ -193,21 +193,24 @@ static int generic_queue_get(const char *printer_name,
        /* turn the lpq output into a series of job structures */
        qcount = 0;
        ZERO_STRUCTP(status);
-       if (numlines)
+       if (numlines) {
                queue = SMB_MALLOC_ARRAY(print_queue_struct, numlines+1);
-
-       if (queue) {
-               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++;
-                       }
-               }               
+               if (!queue) {
+                       file_lines_free(qlines);
+                       *q = NULL;
+                       return 0;
+               }
        }
-       file_lines_free(qlines);
 
+       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;
 }