blf: if there are no log containers, return FALSE when pulling one.

blf_pull_next_logcontainer() shuld check, aftre calling
blf_find_next_logcontainer() to see if the size of the
GArray of log containers is 0; if so, that means no log container was
found, probably because there aren't any to find.

This fixes a case where attempting to read a file with no log containers
causes a crash.
This commit is contained in:
Guy Harris 2024-02-10 19:11:08 -08:00
parent e5c519ba45
commit 8f670352df
1 changed files with 5 additions and 0 deletions

View File

@ -1036,6 +1036,11 @@ blf_pull_next_logcontainer(blf_params_t* params, int* err, gchar** err_info) {
if (!blf_find_next_logcontainer(params, err, err_info)) {
return FALSE;
}
/* Is there a next log container to pull? */
if (params->blf_data->log_containers->len == 0) {
/* No. */
return FALSE;
}
container = &g_array_index(params->blf_data->log_containers, blf_log_container_t, params->blf_data->log_containers->len - 1);
if (!blf_pull_logcontainer_into_memory(params, container, err, err_info)) {
return FALSE;