rewrite the port allocation code to not use freed resources, although this kind of construct likely does not work
rewrite the port allocation code to not use freed resources,
although this kind of construct likely does not work

fixes crashes with AFL

gphoto/libgphoto2,gphoto/libgphoto2,gphoto/libgphoto2,gphoto/libgphoto2,gphoto/libgphoto2,gphoto/libgphoto2