Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 422fca8c authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge changes from topic "am-c41d9dbf-12e7-4386-8be3-987a152ba46e-nyc-dev" into nyc-mr1-dev

* changes:
  [automerger] DO NOT MERGE Truncate new line characters when adding string to config am: f52eea13 am: 44a4d58d
  [automerger] DO NOT MERGE Truncate new line characters when adding string to config am: f52eea13
  DO NOT MERGE Truncate new line characters when adding string to config
parents 5f89bd09 6dea8b37
Loading
Loading
Loading
Loading
+15 −2
Original line number Original line Diff line number Diff line
@@ -34,6 +34,7 @@
#include "osi/include/allocator.h"
#include "osi/include/allocator.h"
#include "osi/include/list.h"
#include "osi/include/list.h"
#include "osi/include/log.h"
#include "osi/include/log.h"
#include "log/log.h"


typedef struct {
typedef struct {
  char *key;
  char *key;
@@ -216,16 +217,28 @@ void config_set_string(config_t *config, const char *section, const char *key, c
    list_append(config->sections, sec);
    list_append(config->sections, sec);
  }
  }


  size_t value_len = strlen(value);
  char *value_no_newline = osi_strdup(value);
  for (size_t i = 0; i < value_len; i++) {
    if (value[i] == '\n') {
      android_errorWriteLog(0x534e4554, "70808273");
      value_no_newline[i] = '\0';
      break;
    }
  }

  for (const list_node_t *node = list_begin(sec->entries); node != list_end(sec->entries); node = list_next(node)) {
  for (const list_node_t *node = list_begin(sec->entries); node != list_end(sec->entries); node = list_next(node)) {
    entry_t *entry = list_node(node);
    entry_t *entry = list_node(node);
    if (!strcmp(entry->key, key)) {
    if (!strcmp(entry->key, key)) {
      osi_free(entry->value);
      osi_free(entry->value);
      entry->value = osi_strdup(value);
      entry->value = osi_strdup(value_no_newline);
      osi_free(value_no_newline);
      return;
      return;
    }
    }
  }
  }


  entry_t *entry = entry_new(key, value);
  entry_t *entry = entry_new(key, value_no_newline);
  osi_free(value_no_newline);
  list_append(sec->entries, entry);
  list_append(sec->entries, entry);
}
}