form: Fix situation where a gadget initialises with NULL value

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This commit is contained in:
Daniel Silverstone 2019-08-04 22:12:10 +01:00
parent 05c6ee02d9
commit b15b204f49
1 changed files with 6 additions and 2 deletions

View File

@ -2269,8 +2269,12 @@ form_gadget_sync_with_dom(struct form_control *control)
control->syncing = true;
/* If we've changed value, sync that toward the DOM */
if ((control->last_synced_value == NULL && control->value[0] != '\0') ||
(control->last_synced_value != NULL && strcmp(control->value, control->last_synced_value) != 0)) {
if ((control->last_synced_value == NULL &&
control->value != NULL &&
control->value[0] != '\0') ||
(control->last_synced_value != NULL &&
control->value != NULL &&
strcmp(control->value, control->last_synced_value) != 0)) {
char *dup = strdup(control->value);
if (dup == NULL) {
goto out;