summaryrefslogtreecommitdiff
path: root/source3/printing/print_generic.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2006-03-08 01:18:18 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 11:11:04 -0500
commit3527b5cc25d4177e860745b16409984610ed11df (patch)
treef3621328b31552ac354c7bc3d0b27346623aa853 /source3/printing/print_generic.c
parentdbbc06db652129986916c503b292ded70f6e8bc9 (diff)
downloadsamba-3527b5cc25d4177e860745b16409984610ed11df.tar.gz
r14003: Clarify code that lead to Coverity report #13.
Not a bug, but better to remove false positives. Jeremy. (This used to be commit f9a75d76546bc4618736f0d48646e77d7572db25)
Diffstat (limited to 'source3/printing/print_generic.c')
-rw-r--r--source3/printing/print_generic.c27
1 files changed, 15 insertions, 12 deletions
diff --git a/source3/printing/print_generic.c b/source3/printing/print_generic.c
index 18fca678600..cb1c951ff74 100644
--- a/source3/printing/print_generic.c
+++ b/source3/printing/print_generic.c
@@ -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;
}