From b3dd287ea0a27788a28a8fe19c43f8231073162a Mon Sep 17 00:00:00 2001 From: turbocat Date: Tue, 2 Mar 2021 20:49:28 +0000 Subject: [PATCH] kolibri-libc: - Fix fwrite and fread working with a void pointer. git-svn-id: svn://kolibrios.org@8627 a494cfbc-eb01-0410-851d-a64ba20cac60 --- contrib/kolibri-libc/source/stdio/fread.c | 2 +- contrib/kolibri-libc/source/stdio/fwrite.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/contrib/kolibri-libc/source/stdio/fread.c b/contrib/kolibri-libc/source/stdio/fread.c index 908bc73ece..31bb3ab5aa 100644 --- a/contrib/kolibri-libc/source/stdio/fread.c +++ b/contrib/kolibri-libc/source/stdio/fread.c @@ -11,7 +11,7 @@ size_t fread(void *restrict ptr, size_t size, size_t nmemb, FILE *restrict strea break; } - ptr[i] = c; + *(char*)(ptr+i) = c; bytes_read++; } diff --git a/contrib/kolibri-libc/source/stdio/fwrite.c b/contrib/kolibri-libc/source/stdio/fwrite.c index 77ca5239bc..0324b2da43 100644 --- a/contrib/kolibri-libc/source/stdio/fwrite.c +++ b/contrib/kolibri-libc/source/stdio/fwrite.c @@ -5,8 +5,7 @@ size_t fwrite(const void *restrict ptr, size_t size, size_t nmemb, FILE *restric unsigned bytes_count = size * nmemb; for (size_t i = 0; i < bytes_count; i++) { - char c = ptr[i]; - + char c = *(char*)(ptr+i); if (fputc(c, stream) != c) { break; }