This is an edge case that will get treated differently in the new peak margin world.
The issue here is that if you have done this as an intraday trade without any margin in your account, there will be a peak margin penalty.
But we are working on a fix for this. If you have sold and bought back in CNC(delivery), we will debit the shares from your Demat and give it to the clearing corp (CC) on trade day (Early payin or EPI), which will get returned back on the same day to your Demat account. This way the shares debited and given to the CC can be considered as peak margin for your intraday short position. We are waiting on some clarity from the clearing corporations to work on this solution. But until then, there will be a peak margin penalty if you sell and buy back without any money in your account.
Check this link to understand more on EPI or Early payin.