This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch main
in repository eradio.
View the commit online.
commit 702d1c5cd701f26ccce212e714b5f42ade9988a2
Author: politebot <[email protected]>
AuthorDate: Wed Oct 22 18:44:08 2025 -0500
Memory fixes
---
.gitignore | 4 +---
Makefile.am | 3 +--
src/Makefile.am | 12 ++++--------
src/favorites.c | 29 +++++++++++++++++++++++++++--
src/http.c | 35 ++++++++++++++++++++++++++++++++---
5 files changed, 65 insertions(+), 18 deletions(-)
diff --git a/.gitignore b/.gitignore
index 597c553..f72c2c9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,10 +9,8 @@ dist/
out/
bin/
-# Test dependencies
+# Vendor dependencies
vendor/
-tests/.deps/
-tests/test_basic
# Autotools generated files
Makefile
diff --git a/Makefile.am b/Makefile.am
index 5eb928c..22cb665 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,9 +2,8 @@ SUBDIRS = src data
EXTRA_DIST = LICENSE README.md
-# Clean distribution from test files and vendor dependencies
+# Clean distribution from vendor dependencies
dist-hook:
@echo "Cleaning distribution..."
- rm -rf $(distdir)/src/tests
rm -rf $(distdir)/src/vendor
@echo "Distribution cleaned successfully"
diff --git a/src/Makefile.am b/src/Makefile.am
index cb2e08c..54745f7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,21 +6,17 @@ eradio_SOURCES = main.c ui.c radio_player.c station_list.c http.c favorites.c vi
eradio_CFLAGS = $(EFL_CFLAGS) $(LIBXML_CFLAGS)
eradio_LDADD = $(EFL_LIBS) $(LIBXML_LIBS)
-# Tests are only built in development, not in distribution
-# The test files are excluded from the distribution package
-
-# Exclude test files and vendor directory from distribution
+# Exclude vendor directory from distribution
nodist_noinst_HEADERS =
-# Don't include test or vendor files in distribution
+# Don't include vendor files in distribution
EXTRA_DIST =
-# Ensure tests and vendor are never included in distribution
+# Ensure vendor is never included in distribution
dist_noinst_DATA =
-# Clean any remaining test/vendor files
+# Clean any remaining vendor files
dist-hook:
@echo "Cleaning distribution..."
- rm -rf $(distdir)/tests
rm -rf $(distdir)/vendor
@echo "Distribution cleaned successfully"
\ No newline at end of file
diff --git a/src/favorites.c b/src/favorites.c
index 80cdf72..c202be2 100644
--- a/src/favorites.c
+++ b/src/favorites.c
@@ -81,12 +81,24 @@ _favorites_hash_add_entry(AppData *ad, const char *key, const char *uuid, const
if (!key || !key[0]) return;
FavEntry *e = calloc(1, sizeof(FavEntry));
if (!e) return;
+
e->key = key ? strdup(key) : NULL;
e->uuid = uuid ? strdup(uuid) : NULL;
e->url = "" ? strdup(url) : NULL;
e->name = name ? strdup(name) : NULL;
e->favicon = favicon ? strdup(favicon) : NULL;
- eina_hash_add(ad->favorites, e->key, e);
+
+ // Add to hash - if this fails, we need to clean up manually
+ if (!eina_hash_add(ad->favorites, e->key, e))
+ {
+ // Manual cleanup since hash add failed
+ free(e->key);
+ free(e->uuid);
+ free(e->url);
+ free(e->name);
+ free(e->favicon);
+ free(e);
+ }
}
void
@@ -277,7 +289,20 @@ static Eina_Bool _favorites_rebuild_cb(const Eina_Hash *hash EINA_UNUSED, const
if (e->uuid) st->stationuuid = eina_stringshare_add(e->uuid);
if (e->favicon) st->favicon = eina_stringshare_add(e->favicon);
st->favorite = EINA_TRUE;
- ad->favorites_stations = eina_list_append(ad->favorites_stations, st);
+
+ // Add to list - check for failure to avoid memory leak
+ Eina_List *new_list = eina_list_append(ad->favorites_stations, st);
+ if (!new_list)
+ {
+ // List append failed, clean up the station
+ eina_stringshare_del(st->name);
+ eina_stringshare_del(st->url);
+ eina_stringshare_del(st->stationuuid);
+ eina_stringshare_del(st->favicon);
+ free(st);
+ return EINA_TRUE;
+ }
+ ad->favorites_stations = new_list;
return EINA_TRUE;
}
diff --git a/src/http.c b/src/http.c
index 7a90665..7fb60cb 100644
--- a/src/http.c
+++ b/src/http.c
@@ -56,6 +56,21 @@ typedef struct _Counter_Download_Context
char stationuuid[128];
} Counter_Download_Context;
+// Helper function to clean up a Station structure
+static void _station_free(Station *st)
+{
+ if (!st) return;
+ eina_stringshare_del(st->name);
+ eina_stringshare_del(st->url);
+ eina_stringshare_del(st->favicon);
+ eina_stringshare_del(st->stationuuid);
+ eina_stringshare_del(st->country);
+ eina_stringshare_del(st->language);
+ eina_stringshare_del(st->codec);
+ eina_stringshare_del(st->tags);
+ free(st);
+}
+
static Eina_Bool _url_data_cb(void *data, int type, void *event_info);
static Eina_Bool _url_complete_cb(void *data, int type, void *event_info);
@@ -390,7 +405,17 @@ _handle_station_list_complete(Ecore_Con_Event_Url_Complete *ev)
xmlFree(prop);
}
- ad->stations = eina_list_append(ad->stations, st);
+ // Add to list - check for failure to avoid memory leak
+ Eina_List *new_list = eina_list_append(ad->stations, st);
+ if (!new_list)
+ {
+ // List append failed, clean up the station
+ _station_free(st);
+ }
+ else
+ {
+ ad->stations = new_list;
+ }
}
favorites_apply_to_stations(ad);
@@ -616,9 +641,11 @@ static void _retry_next_server_station(Ecore_Con_Url *old_url, Station_Download_
xmlFreeParserCtxt(d_ctx->ctxt);
d_ctx->ctxt = NULL;
}
+ // Save ad pointer before freeing context to avoid use-after-free
+ AppData *ad = d_ctx->base.ad;
eina_list_free(d_ctx->servers);
free(d_ctx);
- ui_loading_stop(((Download_Context *)d_ctx)->ad);
+ ui_loading_stop(ad);
}
}
@@ -660,8 +687,10 @@ static void _retry_next_server_counter(Ecore_Con_Url *old_url, Counter_Download_
{
printf("All servers exhausted for counter; giving up.\n");
ecore_con_url_free(old_url);
+ // Save ad pointer before freeing context to avoid use-after-free
+ AppData *ad = c_ctx->base.ad;
eina_list_free(c_ctx->servers);
free(c_ctx);
- ui_loading_stop(((Download_Context *)c_ctx)->ad);
+ ui_loading_stop(ad);
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.