mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-22 20:36:50 +03:00
* background.c (background_attention): Fix memory leak.
This commit is contained in:
parent
5cbfc77d2c
commit
964056fb65
@ -170,6 +170,17 @@ destroy_task_and_return_fd (pid_t pid)
|
|||||||
* specified routine
|
* specified routine
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
static int
|
||||||
|
reading_failed (int i, char **data)
|
||||||
|
{
|
||||||
|
while (i >= 0)
|
||||||
|
g_free (data[i--]);
|
||||||
|
message (D_ERROR, _("Background protocol error"), "%s", _("Reading failed"));
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static int
|
static int
|
||||||
background_attention (int fd, void *closure)
|
background_attention (int fd, void *closure)
|
||||||
{
|
{
|
||||||
@ -234,8 +245,7 @@ background_attention (int fd, void *closure)
|
|||||||
(read (fd, &type, sizeof (type)) != sizeof (type)) ||
|
(read (fd, &type, sizeof (type)) != sizeof (type)) ||
|
||||||
(read (fd, &have_ctx, sizeof (have_ctx)) != sizeof (have_ctx)))
|
(read (fd, &have_ctx, sizeof (have_ctx)) != sizeof (have_ctx)))
|
||||||
{
|
{
|
||||||
message (D_ERROR, _("Background protocol error"), _("Reading failed"));
|
return reading_failed (-1, data);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc > MAXCALLARGS)
|
if (argc > MAXCALLARGS)
|
||||||
@ -249,8 +259,7 @@ background_attention (int fd, void *closure)
|
|||||||
{
|
{
|
||||||
if (read (fd, ctx, sizeof (file_op_context_t)) != sizeof (file_op_context_t))
|
if (read (fd, ctx, sizeof (file_op_context_t)) != sizeof (file_op_context_t))
|
||||||
{
|
{
|
||||||
message (D_ERROR, _("Background protocol error"), _("Reading failed"));
|
return reading_failed (-1, data);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,14 +269,12 @@ background_attention (int fd, void *closure)
|
|||||||
|
|
||||||
if (read (fd, &size, sizeof (size)) != sizeof (size))
|
if (read (fd, &size, sizeof (size)) != sizeof (size))
|
||||||
{
|
{
|
||||||
message (D_ERROR, _("Background protocol error"), _("Reading failed"));
|
return reading_failed (i - 1, data);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
data[i] = g_malloc (size + 1);
|
data[i] = g_malloc (size + 1);
|
||||||
if (read (fd, data[i], size) != size)
|
if (read (fd, data[i], size) != size)
|
||||||
{
|
{
|
||||||
message (D_ERROR, _("Background protocol error"), _("Reading failed"));
|
return reading_failed (i, data);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
data[i][size] = 0; /* NULL terminate the blocks (they could be strings) */
|
data[i][size] = 0; /* NULL terminate the blocks (they could be strings) */
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user