aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apps/browser.c4
-rw-r--r--kernel/features/net.c2
-rw-r--r--libtxt/html.c10
3 files changed, 8 insertions, 8 deletions
diff --git a/apps/browser.c b/apps/browser.c
index 6ed83b2..f00f14b 100644
--- a/apps/browser.c
+++ b/apps/browser.c
@@ -86,8 +86,8 @@ void on_submit(void *event, struct element *box)
struct element_label *c = code_label->data;
- struct socket *socket = net_open(S_TCP);
- if (socket && net_connect(socket, ip, port, NET_TIMEOUT)) {
+ struct socket *socket = NULL;
+ if (ip && (socket = net_open(S_TCP)) && net_connect(socket, ip, port, NET_TIMEOUT)) {
net_send(socket, query, strlen(query));
char *buf = NULL;
if (!(buf = http_receive(socket)) || !html_render(output, http_data(buf), 4096)) {
diff --git a/kernel/features/net.c b/kernel/features/net.c
index ab747e4..be36f14 100644
--- a/kernel/features/net.c
+++ b/kernel/features/net.c
@@ -732,7 +732,7 @@ struct socket *net_open(enum socket_type type)
int net_close(struct socket *socket)
{
- if (!net_installed())
+ if (!net_installed() || !socket)
return 1;
if (socket->state == S_CLOSING)
diff --git a/libtxt/html.c b/libtxt/html.c
index 4fa9789..e1c1246 100644
--- a/libtxt/html.c
+++ b/libtxt/html.c
@@ -62,8 +62,9 @@ static struct dom *generate_dom(char *data, u32 length)
enum xml_error err = xml_parse(&parser, buffer, length, tokens, 128);
if (err != XML_SUCCESS && err != XML_ERROR_BUFFERDRY) {
- printf("\nXML parse error: %d\n", err);
- /* return NULL; */
+ printf("XML parse error: %d\n", err);
+ printf("DATA: '%s'\n", data);
+ return NULL;
}
struct dom *root = new_object("root", NULL);
@@ -113,9 +114,8 @@ static struct dom *generate_dom(char *data, u32 length)
token->end_pos - token->start_pos);
name[token->end_pos - token->start_pos] = '\0';
char *clean_name = name;
- for (u32 j = 0; j < strlen(name); j++) {
- if (name[j] == ' ' || name[j] == '\n' || name[j] == '\r' ||
- name[j] == '\t') {
+ for (char *p = name; *p; p++) {
+ if (*p == ' ' || *p == '\n' || *p == '\r' || *p == '\t') {
clean_name++;
} else {
break;