core: fix crash related to core sockets_list  command
 - reported by Nuno Reis <nreis@wavecom.pt>
(cherry picked from commit 1c715b1a2a66a4a15d1a8def33ef369212712bb1)