/** * Function description * * @return 0 on success, otherwise a Win32 error code */ static UINT read_touch_frame(RdpeiServerContext *context, wStream *s, RDPINPUT_TOUCH_FRAME *frame) { int i; RDPINPUT_CONTACT_DATA *contact; UINT error; if (!rdpei_read_2byte_unsigned(s, &frame->contactCount) || !rdpei_read_8byte_unsigned(s, &frame->frameOffset)) { WLog_ERR(TAG, "rdpei_read_ failed!"); return ERROR_INTERNAL_ERROR; } frame->contacts = contact = calloc(frame->contactCount, sizeof(RDPINPUT_CONTACT_DATA)); if (!frame->contacts) { WLog_ERR(TAG, "calloc failed!"); return CHANNEL_RC_NO_MEMORY; } for (i = 0; i < frame->contactCount; i++, contact++) { if ((error = read_touch_contact_data(context, s, contact))) { WLog_ERR(TAG, "read_touch_contact_data failed with error %lu!", error); frame->contactCount = i; touch_frame_reset(frame); return error; } } return CHANNEL_RC_OK; }
static int read_touch_frame(RdpeiServerContext *context, wStream *s, RDPINPUT_TOUCH_FRAME *frame) { int i; RDPINPUT_CONTACT_DATA *contact; if (!rdpei_read_2byte_unsigned(s, &frame->contactCount) || !rdpei_read_8byte_unsigned(s, &frame->frameOffset)) return -1; frame->contacts = contact = calloc(frame->contactCount, sizeof(RDPINPUT_CONTACT_DATA)); if (!frame->contacts) return -1; for (i = 0; i < frame->contactCount; i++, contact++) { if (read_touch_contact_data(context, s, contact) < 0) { frame->contactCount = i; goto out_cleanup; } } return 0; out_cleanup: touch_frame_reset(frame); return -1; }