Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6969276

minor memory leak detected by cppcheck in agent/src/os/linux/symtab.c

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 7
    • hotspot
    • None
    • svc
    • b02
    • generic
    • generic

      Running cppcheck against hotspot sources found a memory leak:

      [SOURCE:LINE] ERROR DETAIL
      [./agent/src/os/linux/symtab.c:218]: (error) Memory leak: debug_pathname

      We neglect to free debug_pathname in the first case of error return:

        char *debug_pathname = malloc(strlen(debug_filename)
                                      + strlen(name)
                                      + strlen(".debug/")
                                      + strlen(debug_file_directory)
                                      + 2);
        strcpy(debug_pathname, name);
        char *last_slash = strrchr(debug_pathname, '/');
      ! if (last_slash == NULL) {
      + free(debug_pathname); // need to free here
          return -1;
      + }

        /* Look in the same directory as the object. */
        strcpy(last_slash+1, debug_filename);

        debug_fd = open_debug_file(debug_pathname, crc);
        if (debug_fd >= 0) {
          free(debug_pathname);
          return debug_fd;
        }
        ...

            dsamersoff Dmitriy Samersoff
            dholmes David Holmes
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: