From 951d3a804936bef13e11853cb598010666f59fa5 Mon Sep 17 00:00:00 2001
From: Andreas Mohr <and@gmx.li>
Date: Tue, 18 May 2021 15:14:16 +0000
Subject: [PATCH] (background.c) fix argument cannot be negative
Fix argument cannot be negative
Found by Coverity
Coverity id #32593
Signed-off-by: Andreas Mohr <and@gmx.li>
---
src/background.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/src/background.c b/src/background.c
index 584cd74ef..66b7c3d37 100644
a
|
b
|
background_attention (int fd, void *closure) |
332 | 332 | } |
333 | 333 | |
334 | 334 | /* Send the result code and the value for shared variables */ |
335 | | ret = write (to_child_fd, &result, sizeof (result)); |
336 | | if (have_ctx != 0 && to_child_fd != -1) |
337 | | ret = write (to_child_fd, ctx, sizeof (*ctx)); |
| 335 | if (to_child_fd != -1) |
| 336 | { |
| 337 | ret = write (to_child_fd, &result, sizeof (result)); |
| 338 | if (have_ctx != 0) |
| 339 | ret = write (to_child_fd, ctx, sizeof (*ctx)); |
| 340 | } |
338 | 341 | } |
339 | 342 | else if (type == Return_String) |
340 | 343 | { |
… |
… |
background_attention (int fd, void *closure) |
368 | 371 | if (resstr != NULL) |
369 | 372 | { |
370 | 373 | len = strlen (resstr); |
371 | | ret = write (to_child_fd, &len, sizeof (len)); |
372 | | if (len != 0) |
373 | | ret = write (to_child_fd, resstr, len); |
| 374 | if (to_child_fd != -1) |
| 375 | { |
| 376 | ret = write (to_child_fd, &len, sizeof (len)); |
| 377 | if (len != 0) |
| 378 | ret = write (to_child_fd, resstr, len); |
| 379 | } |
374 | 380 | g_free (resstr); |
375 | 381 | } |
376 | 382 | else |
377 | 383 | { |
378 | 384 | len = 0; |
379 | | ret = write (to_child_fd, &len, sizeof (len)); |
| 385 | if (to_child_fd != -1) |
| 386 | ret = write (to_child_fd, &len, sizeof (len)); |
380 | 387 | } |
381 | 388 | } |
382 | 389 | |