lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [bug #64409] When tcp_err() is invoked, tcp_pcb is freed bu


From: Hungyin Chang
Subject: [lwip-devel] [bug #64409] When tcp_err() is invoked, tcp_pcb is freed but fs_close_custom() is not called by httpd.c
Date: Tue, 11 Jul 2023 05:58:20 -0400 (EDT)

URL:
  <https://savannah.nongnu.org/bugs/?64409>

                 Summary: When tcp_err() is invoked, tcp_pcb is freed but
fs_close_custom() is not called by httpd.c
                   Group: lwIP - A Lightweight TCP/IP stack
               Submitter: zlk1214
               Submitted: Tue 11 Jul 2023 09:58:19 AM UTC
                Category: Contrib
                Severity: 3 - Normal
              Item Group: Feature Request
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None
            lwIP version: 2.1.3


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Tue 11 Jul 2023 09:58:19 AM UTC By: Hungyin Chang <zlk1214>
When LWIP_HTTPD_CUSTOM_FILES=1 and LWIP_HTTPD_FS_ASYNC_READ=0, the user can
implement the following three functions to dynamically load webpages from
disk.
int fs_open_custom(struct fs_file *file, const char *name);
void fs_close_custom(struct fs_file *file);
int fs_read_custom(struct fs_file *file, char *buffer, int count);

If a file handle is allocated in fs_open_custom(), then it should be freed in
fs_close_custom().
However, when tcp_err() event happens, http_err() in httpd.c does NOT call any
of the functions above. Therefore, the file handle cannot be freed, casuing
memory leak.

altcp_err(pcb, http_err);
/**
* The pcb had an error and is already deallocated.
* The argument might still be valid (if != NULL).
 */
static void
http_err(void *arg, err_t err)
{
  struct http_state *hs = (struct http_state *)arg;
  LWIP_UNUSED_ARG(err);

  LWIP_DEBUGF(HTTPD_DEBUG, ("http_err: %s\n", lwip_strerr(err)));

  if (hs != NULL) {
    http_state_free(hs);
  }
}

In my opinion, fs_close_custom() should be called in http_err().







    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/bugs/?64409>

_______________________________________________
Message sent via Savannah
https://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]