I am having an issue where valgrind is saying that i have a conditional jump or the move depends on initialized values
#include <stdio.h>
#include<stdlib.h>
ListNodePtr convertBSTtoLinkedList(TreeNodePtr root)
{
ListNodePtr newNode;
ListNodePtr leftLinkedList;
ListNodePtr rightLinkedList;
ListNodePtr head;
if (root == NULL)
{
return NULL;
}
newNode = malloc(sizeof(struct ListNode));
newNode->key = root->key;
head = newNode;
if(root->left != NULL)
{
leftLinkedList = convertBSTtoLinkedList(root->left);
head = leftLinkedList;
ListNodePtr conductor;
conductor = leftLinkedList;
while (conductor->next != NULL)
{
conductor = conductor->next;
}
conductor->next = newNode;
}
if(root->right != NULL)
{
rightLinkedList= convertBSTtoLinkedList(root->right);
newNode->next = rightLinkedList;
}
return head;
}
valgrind the problem is somewhere in the while loop and i am assuming it is because i havent initialized that conductor->next is NULL, but i dont know how to do that since it it checking if it is NULL