summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hindoe Paaboel Andersen <phomes@gmail.com>2015-08-13 23:36:08 +0200
committerThomas Hindoe Paaboel Andersen <phomes@gmail.com>2015-08-13 23:53:49 +0200
commit88231eb62cafc8bb51406919c8cf6019dc1ac916 (patch)
tree366a3334e21b37251b9bfb07a9404b153edddabf
parent3326332eb9d4eac00c4e543fcdde9e5c0720c23d (diff)
logind: actually fail on OOM
Since dacd6cee76a08331b8c8616c5f30f70ee49aa2f9 the two OOM's are ignored as the value of r will be overwritten and we only log in the fail section anyway. This patch jumps to fail on OOM. Note that this is different behavior compared to both the current code and previous to dacd6cee76a08331b8c8616c5f30f70ee49aa2f9. Before that commit we would log that saving the inhibit data failed, but still write the file, though without the WHO/WHY section. CID# 1313545
-rw-r--r--src/login/logind-inhibit.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/login/logind-inhibit.c b/src/login/logind-inhibit.c
index a261e6a719..cfae186edd 100644
--- a/src/login/logind-inhibit.c
+++ b/src/login/logind-inhibit.c
@@ -109,20 +109,24 @@ int inhibitor_save(Inhibitor *i) {
_cleanup_free_ char *cc = NULL;
cc = cescape(i->who);
- if (!cc)
+ if (!cc) {
r = -ENOMEM;
- else
- fprintf(f, "WHO=%s\n", cc);
+ goto fail;
+ }
+
+ fprintf(f, "WHO=%s\n", cc);
}
if (i->why) {
_cleanup_free_ char *cc = NULL;
cc = cescape(i->why);
- if (!cc)
+ if (!cc) {
r = -ENOMEM;
- else
- fprintf(f, "WHY=%s\n", cc);
+ goto fail;
+ }
+
+ fprintf(f, "WHY=%s\n", cc);
}
if (i->fifo_path)