#736 Memory leak in the comment management
Closed: Fixed Opened by dpal.

In ini/ini_comment.c

The check is incorrect.

         case INI_COMMENT_MODE_INSERT:
  288
  289        TRACE_INFO_STRING("Insert mode", "");
  290        len = ref_array_len(ic->ra);
  291        if (idx > len) {
  292            /* Fill in empty lines */
  293            for (i = 0; i < (idx-len); i++) {
Calling allocation function "calloc".
Assigning: "empty" = storage returned from "calloc(1UL, 1UL)".
  294                empty = strdup("");
At conditional (1): "empty" taking the true branch.
  295                if (empty) {
  296                    TRACE_ERROR_NUMBER("Memory problem", ENOMEM);
Variable "empty" going out of scope leaks the storage it points to.
  297                    return ENOMEM;
  298                }
  299                error = ref_array_append(ic->ra, (void *)&empty);
  300                if (error) {
  301                    TRACE_ERROR_NUMBER("Append problem", error);
  302                    free(empty);
  303                    return error;
  304                }
  305                error = ref_array_append(ic->ra_len, (void *)&input_len);
  306                if (error) {
  307                    TRACE_ERROR_NUMBER("Error adding lenghts", error);
  308                    free(empty);
  309                    return error;
  310                }

Fields changed

summary: Memory leak in the comment managment => Memory leak in the comment management

Fields changed

coverity: => 10041
keywords: => Coverity

This code is fixed on master. It is Ok to ignore it on the release branch since this code path is not executed yet.

Fields changed

resolution: => fixed
status: new => closed

Fields changed

rhbz: => 0

Metadata Update from @dpal:
- Issue set to the milestone: Tools Backlog

Metadata