There's no length check in this function, so it's possible for num to be set to garbage.   As you already submitted a patch against the old function, perhaps it'd be best to just update this function now.