Fix #35570, old group nodes with empty socket name strings crash. The identifier assignment was not taking potentially empty name strings into account. In addition some of the BLI_uniquename calls were

not passing a valid defname parameter, also crashing.
This commit is contained in:
Lukas Toenne 2013-05-30 11:51:21 +00:00
parent 79f5a013be
commit 281e538be0
2 changed files with 5 additions and 5 deletions

@ -475,7 +475,7 @@ static bNodeSocket *make_socket(bNodeTree *ntree, bNode *UNUSED(node), int in_ou
BLI_strncpy(auto_identifier, name, sizeof(auto_identifier));
}
/* make the identifier unique */
BLI_uniquename_cb(unique_identifier_check, lb, NULL, '.', auto_identifier, sizeof(auto_identifier));
BLI_uniquename_cb(unique_identifier_check, lb, "socket", '.', auto_identifier, sizeof(auto_identifier));
sock = MEM_callocN(sizeof(bNodeSocket), "sock");
sock->in_out = in_out;

@ -7770,20 +7770,20 @@ static void do_versions_nodetree_customnodes(bNodeTree *ntree, int UNUSED(is_gro
for (node=ntree->nodes.first; node; node=node->next) {
for (sock = node->inputs.first; sock; sock = sock->next) {
BLI_strncpy(sock->identifier, sock->name, sizeof(sock->identifier));
BLI_uniquename(&node->inputs, sock, sock->identifier, '.', offsetof(bNodeSocket, identifier), sizeof(sock->identifier));
BLI_uniquename(&node->inputs, sock, "socket", '.', offsetof(bNodeSocket, identifier), sizeof(sock->identifier));
}
for (sock = node->outputs.first; sock; sock = sock->next) {
BLI_strncpy(sock->identifier, sock->name, sizeof(sock->identifier));
BLI_uniquename(&node->outputs, sock, sock->identifier, '.', offsetof(bNodeSocket, identifier), sizeof(sock->identifier));
BLI_uniquename(&node->outputs, sock, "socket", '.', offsetof(bNodeSocket, identifier), sizeof(sock->identifier));
}
}
for (sock = ntree->inputs.first; sock; sock = sock->next) {
BLI_strncpy(sock->identifier, sock->name, sizeof(sock->identifier));
BLI_uniquename(&ntree->inputs, sock, sock->identifier, '.', offsetof(bNodeSocket, identifier), sizeof(sock->identifier));
BLI_uniquename(&ntree->inputs, sock, "socket", '.', offsetof(bNodeSocket, identifier), sizeof(sock->identifier));
}
for (sock = ntree->outputs.first; sock; sock = sock->next) {
BLI_strncpy(sock->identifier, sock->name, sizeof(sock->identifier));
BLI_uniquename(&ntree->outputs, sock, sock->identifier, '.', offsetof(bNodeSocket, identifier), sizeof(sock->identifier));
BLI_uniquename(&ntree->outputs, sock, "socket", '.', offsetof(bNodeSocket, identifier), sizeof(sock->identifier));
}
}
}