Как починить conditional jump?
При проверке через valgrind вылазит conditional jump. Предположительно ошибка возникает в функции input, но я не знаю как починить.
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct Item {
int data;
struct Item* next;
} Item;
typedef struct Queue{
Item* head;
Item* tail;
} Queue;
void input(Queue* list,int* stroka) {
Item* new = (Item*)malloc(sizeof(Item));
new->data = *stroka;
new->next = NULL;
if (!list->head) {
list->head = new;
list->tail = new;
} else {
list->tail->next = new;
list->tail = new;
}
}
void print(const Queue* list) {
Item* ptr = list->head;
while(ptr) {
printf("%c", ptr->data);
ptr = ptr->next;
}
}
int main() {
int stroka;
Queue* list = (Queue*)malloc(sizeof(Queue));
stroka = '"';
input(list, &stroka);
while(stroka != EOF) {
stroka = getchar();
if (stroka == EOF) {
stroka = '"';
input(list, &stroka);
break;
}
input(list, &stroka);
}
printf("\n");
print(list);
}
Conditional jump or move depends on uninitialised value(s)
==29969== at 0x10931A: input ()
==29969== by 0x1093CF: main ()
==29969== Uninitialised value was created by a heap allocation
==29969== at 0x48427B5: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
==29969== by 0x1093B1: main ()
Источник: Stack Overflow на русском