aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorMarvin Borner2021-05-15 22:36:21 +0200
committerMarvin Borner2021-05-15 22:36:21 +0200
commitdf5a8c5b32733ae5e2d872b1c7baa4311a9d2308 (patch)
tree460b35ad421bc74e75e942a35379621ba168c9ea /libs
parentf97343c268b0fc19bf93d509a019f3d13c7af5a4 (diff)
Strange fixes
I have no ideas halp
Diffstat (limited to 'libs')
-rw-r--r--libs/libc/conv.c4
-rw-r--r--libs/libc/inc/print.h2
-rw-r--r--libs/libc/list.c7
-rw-r--r--libs/libc/sanitize.c2
-rw-r--r--libs/libc/stack.c7
-rw-r--r--libs/libgui/png.c13
-rw-r--r--libs/libnet/ip.c3
7 files changed, 23 insertions, 15 deletions
diff --git a/libs/libc/conv.c b/libs/libc/conv.c
index bb68d7b..668069c 100644
--- a/libs/libc/conv.c
+++ b/libs/libc/conv.c
@@ -123,7 +123,7 @@ char *conv_base(int value, char *result, int base, int is_signed)
return result;
}
- char *ptr = result, *ptr1 = result, tmp_char;
+ char *ptr = result, *ptr1 = result;
int tmp_value;
do {
@@ -137,7 +137,7 @@ char *conv_base(int value, char *result, int base, int is_signed)
*ptr++ = '-';
*ptr-- = '\0';
while (ptr1 < ptr) {
- tmp_char = *ptr;
+ char tmp_char = *ptr;
*ptr-- = *ptr1;
*ptr1++ = tmp_char;
}
diff --git a/libs/libc/inc/print.h b/libs/libc/inc/print.h
index 6d959c3..bc1b7b0 100644
--- a/libs/libc/inc/print.h
+++ b/libs/libc/inc/print.h
@@ -20,7 +20,7 @@ int viprintf(enum io_type io, const char *format, va_list ap) NONNULL;
int fprintf(const char *path, const char *format, ...) NONNULL;
int iprintf(enum io_type io, const char *format, ...) NONNULL;
int log(const char *format, ...) NONNULL;
-void err(int code, const char *format, ...) NONNULL;
+NORETURN void err(int code, const char *format, ...) NONNULL;
#else
#include <proc.h>
int print_prefix(void);
diff --git a/libs/libc/list.c b/libs/libc/list.c
index 53bfa08..bda9e20 100644
--- a/libs/libc/list.c
+++ b/libs/libc/list.c
@@ -22,11 +22,12 @@ void list_destroy(struct list *list)
break;
}
iterator = iterator->next;
- free(iterator->prev);
+
+ if (iterator && iterator->prev)
+ free(iterator->prev);
}
- list->head = NULL;
+ memset(list, 0, sizeof(*list));
free(list);
- list = NULL;
}
static struct node *list_new_node(void)
diff --git a/libs/libc/sanitize.c b/libs/libc/sanitize.c
index d31c20c..00c9032 100644
--- a/libs/libc/sanitize.c
+++ b/libs/libc/sanitize.c
@@ -183,7 +183,7 @@ void __ubsan_handle_type_mismatch_v1(struct type_mismatch *data, u32 ptr)
};
struct source_location *loc = &data->location;
- const char *msg = "";
+ const char *msg;
if (ptr == 0) {
msg = "null pointer";
} else if (data->alignment != 0 && is_aligned(ptr, data->alignment))
diff --git a/libs/libc/stack.c b/libs/libc/stack.c
index 6f16709..81c76a2 100644
--- a/libs/libc/stack.c
+++ b/libs/libc/stack.c
@@ -22,11 +22,12 @@ void stack_destroy(struct stack *stack)
break;
}
iterator = iterator->prev;
- free(iterator->next);
+
+ if (iterator && iterator->prev)
+ free(iterator->prev);
}
- stack->tail = NULL;
+ memset(stack, 0, sizeof(*stack));
free(stack);
- stack = NULL;
}
static struct stack_node *stack_new_node(void)
diff --git a/libs/libgui/png.c b/libs/libgui/png.c
index 2ff3340..c405c3c 100644
--- a/libs/libgui/png.c
+++ b/libs/libgui/png.c
@@ -381,8 +381,10 @@ static long png_filesize(const char *filename)
/* load file into buffer that already has the correct allocated size. Returns error code.*/
static u32 png_buffer_file(u8 *out, u32 size, const char *filename)
{
- u32 readsize;
- readsize = read(filename, out, 0, size);
+ if (!out)
+ return 78;
+
+ u32 readsize = read(filename, out, 0, size);
if (readsize != size)
return 78;
@@ -3730,7 +3732,12 @@ static void getPixelColorRGBA8(u8 *r, u8 *g, u8 *b, u8 *a, const u8 *in, u32 i,
1U); /*highest possible value for this bit depth*/
u32 j = i * mode->bitdepth;
u32 value = readBitsFromReversedStream(&j, in, mode->bitdepth);
- *r = *g = *b = (value * 255) / highest;
+
+ if (highest)
+ *r = *g = *b = (value * 255) / highest;
+ else
+ *r = *g = *b = value;
+
if (mode->key_defined && value == mode->key_r)
*a = 0;
else
diff --git a/libs/libnet/ip.c b/libs/libnet/ip.c
index 20e1a38..66fd8eb 100644
--- a/libs/libnet/ip.c
+++ b/libs/libnet/ip.c
@@ -12,13 +12,12 @@ int ip_pton(const char *src, u32 *dst)
{
const char *end = src + strlen(src);
u8 tmp[4], *tp;
- int ch = 0;
int saw_digit = 0;
int octets = 0;
*(tp = tmp) = 0;
while (src < end) {
- ch = *src++;
+ int ch = *src++;
if (ch >= '0' && ch <= '9') {
u32 new = *tp * 10 + (ch - '0');