Merge lp:~azzar1/indicator-printers/fix-1703046 into lp:indicator-printers

Proposed by Andrea Azzarone on 2017-10-20
Status: Merged
Approved by: Marco Trevisan (Treviño) on 2017-10-21
Approved revision: 84
Merged at revision: 84
Proposed branch: lp:~azzar1/indicator-printers/fix-1703046
Merge into: lp:indicator-printers
Diff against target: 20 lines (+6/-3)
1 file modified
src/indicator-printers-menu.c (+6/-3)
To merge this branch: bzr merge lp:~azzar1/indicator-printers/fix-1703046
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) 2017-10-20 Approve on 2017-10-21
Review via email: mp+332554@code.launchpad.net

Commit message

According to the documentation cupsGetOptions can return NULL. Do not crash if it happens.

To post a comment you must log in.
Marco Trevisan (Treviño) (3v1n0) wrote :

Ack!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/indicator-printers-menu.c'
2--- src/indicator-printers-menu.c 2012-03-03 10:40:46 +0000
3+++ src/indicator-printers-menu.c 2017-10-20 09:39:59 +0000
4@@ -220,10 +220,13 @@
5
6 ndests = cupsGetDests (&dests);
7 for (i = 0; i < ndests; i++) {
8- int state = atoi (cupsGetOption ("printer-state",
9+ const char *val = cupsGetOption ("printer-state",
10 dests[i].num_options,
11- dests[i].options));
12- update_printer_menuitem (self, dests[i].name, state);
13+ dests[i].options);
14+ if (val != NULL) {
15+ int state = atoi (val);
16+ update_printer_menuitem (self, dests[i].name, state);
17+ }
18 }
19 cupsFreeDests (ndests, dests);
20 }

Subscribers

People subscribed via source and target branches