I have looked at previous similar questions, but I am still not very clear on this. Most real-time or otherwise fft functions suggest adding zeros at the end of the input to make the sample size an integer exponent of 2 and make the resolution better (as the step size of the output is inversely proportional to the number of samples at the input).
What I do not understand is, wouldn't adding the zeros affect the output spectrum (amplitude at each frequency in output data) if we add zeros to the input signal? My understanding is that the fft function considers the sample data as periodic and thus adding zero will add a sharp fall in signal amplitude and thus would introduce wrong amplitudes/ energy distribution in higher frequencies of the output. The exact reason we add a windowing function to signals for.
I tested this using the rfft function provided by CMSIS library of STM32. I generated a sample sine wave and passed on data to the rfft function. I changed the data length such that in one case I do not need to add zeros to get $2^n$ samples and other case I had to. The results with zero padded data looked very different from the non padded signals.
Spectrum analysis from this page also confirms this observation. The spectrum on left without zero padding gives more realistic amplitudes of frequencies other than the peak, while the one with padding gives higher magnitudes for other frequencies (shown with red lines on left side of spectrum). The right side spectrum is probably distorted in first image too because of the time domain signal not being complete cycles of the waveform.