在 2023/4/6 16:28, Martin Storsjö 写道:
diff --git a/mingw-w64-crt/crt/tls_atexit.c b/mingw-w64-crt/crt/tls_atexit.c
index f39731ad7..284fd675d 100644
--- a/mingw-w64-crt/crt/tls_atexit.c
+++ b/mingw-w64-crt/crt/tls_atexit.
@@ -54,12 +54,13 @@ int __mingw_cxa_atexit(dtor_fn dtor, void *obj, void *dso) {
  }
static void run_dtor_list(dtor_obj **ptr) {
-  dtor_obj *list = *ptr;
-  while (list) {
-    list->dtor(list->obj);
-    dtor_obj *next = list->next;
-    free(list);
-    list = next;
+  if (!ptr)
+    return;
+  while (*ptr) {
+    dtor_obj *cur = *ptr;
+    *ptr = cur->next;
+    cur->dtor(cur->obj);
+    free(cur);
    }
    *ptr = NULL;
      ^^^^^^^^^^^

This assignment is now redundant and should be deleted.

The other parts look good to me. I don't like the idea about allocating storage for something just a pointer, but given how `run_dtor_list()` is implemented, that makes some sense on its own.


--
Best regards,
LIU Hao

Attachment: OpenPGP_signature
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to