Skip to content

Commit 877bbb6

Browse files
authored
Merge pull request #48 from tronbyt/catch_bad_url_in_http
catch error when http init fails from bad url to avoid barf.
2 parents b0d7ff9 + bb7ccbe commit 877bbb6

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/remote.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,11 @@ int remote_get(const char* url, uint8_t** buf, size_t* len, uint8_t* brightness_
159159
};
160160

161161
esp_http_client_handle_t http = esp_http_client_init(&config);
162+
if (http == NULL) {
163+
ESP_LOGE(TAG, "HTTP client initialization failed for URL: %s", url);
164+
free(state.buf);
165+
return 1;
166+
}
162167

163168
// Do the request
164169
esp_err_t err = esp_http_client_perform(http);

src/wifi.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ static void connect_to_ap(void);
142142
static void url_decode(char *str);
143143
static bool has_saved_config = false;
144144
// Initialize WiFi
145-
int
146-
wifi_initialize(const char *ssid, const char *password) {
145+
int wifi_initialize(const char *ssid, const char *password) {
147146
ESP_LOGI(TAG, "Initializing WiFi");
148147

149148
// Initialize NVS

0 commit comments

Comments
 (0)