Skip to content

Commit 942f407

Browse files
Shwetha-Acharyaanoopcs9
authored andcommitted
source3/printing: Fix CID 1273086 - Resource Leak
Ensure print_queue_struct *q is initialized to NULL to avoid undefined behavior when freeing on error paths. Move SAFE_FREE(q) outside the ret > 0 block to ensure q is always freed. Signed-off-by: Shwetha K Acharya <Shwetha.K.Acharya@ibm.com> Reviewed-by: Guenther Deschner <gd@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Anoop C S <anoopcs@samba.org> Reviewed-by: Vinit Agnihotri <vagnihot@redhat.com> Autobuild-User(master): Anoop C S <anoopcs@samba.org> Autobuild-Date(master): Tue Aug 5 09:20:17 UTC 2025 on atb-devel-224
1 parent 6d86e6e commit 942f407

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

source3/printing/print_generic.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ static int generic_job_submit(int snum, struct printjob *pjob,
225225
char *jobname = NULL;
226226
TALLOC_CTX *ctx = talloc_tos();
227227
fstring job_page_count, job_size;
228-
print_queue_struct *q;
228+
print_queue_struct *q = NULL;
229229
print_status_struct status;
230230

231231
/* we print from the directory path to give the best chance of
@@ -299,7 +299,6 @@ static int generic_job_submit(int snum, struct printjob *pjob,
299299
break;
300300
}
301301
}
302-
SAFE_FREE(q);
303302
ret = 0;
304303
}
305304
if (pjob->sysjob == -1) {
@@ -313,6 +312,7 @@ static int generic_job_submit(int snum, struct printjob *pjob,
313312
if (chdir(current_directory) == -1) {
314313
smb_panic("chdir failed in generic_job_submit");
315314
}
315+
SAFE_FREE(q);
316316
TALLOC_FREE(current_directory);
317317
return ret;
318318
}

0 commit comments

Comments
 (0)