What is the value is 'i'?
Are you sure that malloc is actually implemented in the library that you are using?
Some libraries actually only return NULL as it is not really implemented.
There may be a library flag in the IDE or Makefile that gets a real malloc.
Also check the linker script. Is there really a Heap for malloc to draw memory from?
In general malloc in embedded systems is a bad idea and why MISRA discourages its use.